javascript - Double curly braces {{}} problem in angular.js
ringa_lee
ringa_lee 2017-07-04 13:44:52
0
4
1880

这是列表页面

As the title says, in the above code, I need to get the $index value as a parameter. I need to add {{}} to the first li to get the value, but there is no need to add it to the second li; how should I do this? distinguish? ?

ringa_lee
ringa_lee

ringa_lee

reply all (4)
伊谢尔伦

In order to parse data in native HTML, you need to use {{}} to bind data, but there is no need for this behind the ng command.

    伊谢尔伦

    {{ $var }}wrappedtemplate variable, used whendirectly output the variable valuewithout additional parsing (such as filter processing, as an instruction parameter, as a function parameter), otherwise,ng -click="jump('/myDetail/'+ $index)"is theparametercalled in the command.

      ringa_lee

      The simple criterion is

      • If the type assigned to the current attribute is a literal type, such as an attribute in an html template, or an attribute with@as a modifier in a directive, then if you do not add double curly brackets when assigning the value, it will be a literal value. To calculate, if you want to parse it as a variable, you need to add double curly braces.

      • If the type assigned to the current attribute is a non-string type, such as various built-in instructions in the angular template, or attributes modified with<,=,&in the instructions, then the assignment will be as follows The syntax rules of js are parsed. In this case, there is no need to add curly brackets.

        滿天的星座

        First explain the two types in Angular:

        Template: The format is{{...}}, which is essentially a string, and will be expanded into a recognizable string text by the parsing engine
        Expression: code that can be run directly, basically the same as JS writing, except Allthisomitted.

        Then you can refer to the context to determine whether you are writing a JS-like part or writing a string literal, so that it is easy to judge whether you need a template or an expression.

          Latest Downloads
          More>
          Web Effects
          Website Source Code
          Website Materials
          Front End Template
          About us Disclaimer Sitemap
          php.cn:Public welfare online PHP training,Help PHP learners grow quickly!