javascript - AngularJS Directives: Inserting Attribute values in template -


I am quite new to AngularJS, and I have the following problem.

I have an HTML element:

  & lt; Div class = "hn-multi-select" array-of-strings = "testArray" & gt; & Lt; / Div & gt;  

More Director:

  Angular Modules ('Directives') Directive ('arrayfosting', function ($ Rootscope)) {return {scope: {Pahn: '= arrayOfStrings'}, Template:' & lt; Div & gt; & Lt; Input type = "text" & gt; + '& Lt; Select name = "" id = "multiple ng-model =" page "ng-option =" dm for dm in pnm "& gt; & Lt; / Select & gt; & Lt; / Div & gt; Replace: correct, compile: function compilation (Tilement, TATRS, transclusion) {return} pre-function pre link (scope, ielm), iAttrs) {}, post: function postlink (scope, iElem, iAttrs) {}}} }}}});  

What I want to achieve is that you have an array in the html component array-of-string = "dModelTest" (object with the object that has the Enter the attribute name) Enter This array is passed to the Directorate, which creates a selection list with all the components outside that array.

Everything is fine, but I want to make it the appropriate template with the array- string and that information.

It still shows in the webpage:

  & lt; Name name = "" id = "" multiple = "" ng-model = "pahn" ng-option = "DM for DM in name." Class = "ng-print ng-valid" & gt; & Lt; / Select & gt;  

But it should

  & lt; Select name = "" id = "" multiple = "" ng-model = "dModelTest" should be seen as NG - petition = "DMName for DM, in DMDTest" class = "ng-prestestinate ng-valid" & Gt; & Lt; / Select & gt;  

Do you have any suggestions for that problem?

In your code, you can display the value of each item

  ng -options = "Forgot to declare dm for DM as DM" as dm  

In addition, in your case you do not need to override the compile function It is enough to define a template.

Here is an example hope is that it will help you.

  .controller ('parentcontroller', function ($ scope) {$ scope.array = [{name: 'hi'}, {name: 'ho' }, {Name: 'hu'}]}} Restrict: 'A', Replace: Correct, Template: '& lt; div & gt; & lt; directive (' to selectlist ', function () {return: scope: {pahn:' = to selectlist}}; Input type = "text" ng-model = "selectedValue.name"> Select '+' & lt; ng-model = "selectedValue" ng-option = "DM-DM is the array of dynamic objects And makes a selection list with them. 

>

Item name from input text Is linked


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -