Sunday, 15 April 2012

angularjs - Binding global scope variable to directive local variable -


I'm having trouble understanding the area to connect between the controllers and the instructions.

What I'm trying to do is force data in my controller in my command $ scope.systems .

So I setup simple directive call:

  & lt; Kamboox Data = "System" & gt; & Lt; / Combobox & gt;  

I also tried to force the variable, but I did not understand it.

  & lt; Combobox data = "{{systems}}" & Lt; / Told & gt;  

Then I created my driver like

 . Directive ('combobox', function (timeout)) {return {restricted: 'e', ​​substituting: true, templateUrl: '/angular/directives/combobox.php', link: function (scope, element, ethers) {console .log (attrs.data); $ Timeout (function () {console.log (scope.systems)); Console.log ($ scope [attrs.data]);}, 1000);}}});  

I'm supposed to add a scope parameter to a guided return

  scope: {'systems': '='}  

or

  scope: {'system': '= data'}  

I am able to set simple directions where Values ​​are within the scope of the instruction, and they have worked, now I am trying to prepare a reusable instruction where I can tell which data is used from the controller area I have to do it, and I'm stuck now.

This should work though I'm not sure why your template is a php file ... < / P>

  & lt; Combobox data = "foo" & gt; & Lt; / Combobox & gt; & Lt; Kamboox data = "bar" & gt; & Lt; / Cambodia & gt; App.directive ('combobox', function ($ timeout)) {return {restrict: 'e', ​​replace: true, scope: {// it will set $ scope.systems // / data attribute 'system' : '= Data'}, templateUrl: '/angular/directives/combobox.php', link: function (region, element, etter) {console.log (scope.systems);}}}); Do not use  

replace BTW, . The Kangra team said that this will probably disappear soon because it is causing too many issues and is not necessarily anyway.


No comments:

Post a Comment