Saturday 15 February 2014

angularjs - String Interpolation Won't Work when Setting Attribute Values on a Custom Directive -


Can I pass attributes from a $ radius into a custom command like this?

  & lt; Div ng-repeat = "scalable in scalable" & gt; & Lt; Div & gt; How much do you like {{ratable.name}}? & Lt; / Div & gt; & Lt ;! - Hardcore - First element does not work, second element - & gt; & Lt; Rating currentRatingValue = "{{ratable.currentvalue}}" maxRatingValue = "10" & gt; & Lt; / Ratings & gt; & Lt; / Div & gt; It is okay with the hardness "10" instruction, but string launches never seems like when I try to pass {{ratable.currentvalue}}. Am I doing something wrong?  

  var myApp = angular.module ('myApp', []). {{Currentratingvalue}} current outside {{max}} {{max}} {{/ lt; / div & gt; ", link: function: {god}" {{maxratingvalue}} Rating: "E", Scope: {}, Template: "
Hello, {{ Name}}! & Lt; div ng- repeat = "titable in lime" & gt; & lt; div & gt; how much do you like {{ratable.name}}? & Lt; / div & gt; & lt; - Hardcore - The first element does not work, second element -> Rating currentRatingValue = "{{ratable.currentvalue}}" maxRatingValue = "10" & gt; & Lt; / Ratings & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;

Some things:

  • Directive attributes to HTML The need to use kebab-case
  • You do not need a separate scope (actually causing this problem); Instead use the scope: true
  • so that you can set the local scope property so that your template can choose them
  • $ inspection Interpolated attributes are used to get the value (i.e., the properties that use {{}}}

    HTML:

          

    Director:

      Link: Function (scope, element, attributes) {attributes. $ Inspection ('currentRatingValue', function (newValue) {console log ('newValue =', newValue); scope.currentRatingValue = newValue}) scope.maxRatingValue = attributes.maxRatingValue; console Here is a version that uses a different scope:   

    (Current rating: {{currentRatingValue}} "+ {{restricted:" e ", scope: {currentRatingValue: '@', maxRatingValue: '@ '}, Template: "& lt; Div class = 'rating' "{{maxRatingValue}} outside & lt; / div & gt;",};});

    If you want to see the value of different scope property in your link function, then you should see $ inspection or $ Watch Because if we used '@' if you use '=' (for double-sided databasing), then you should see $ inspection or $ watch < No need to use / code>.

No comments:

Post a Comment