angularjs - Can multiple directives for one element share an isolated scope? -


Two instructions on the same element can not have a separate scope for both, but are they both distinct and distinct from their parents You can use? And can they force both the qualities to separate scope? For example, if I have two instructions on an element

     

And one instruction defines a separate scope with a separate asset

  App.directive ('e directive', function () {return { Restrict: 'E', scope: {localProp: '= prop'}, ...};});   

What other instructions can get that radius and can he use the forced asset? Restrict: 'A', link: function postlink (scope, element, ethers) {scope. $ Watch ('localprop') ', Function (newprap, old prop) {...}}, ...};})

My initial attempt (coded as the top) failed.

I recommend that you use the instructions for secondary instruction to communicate between the controllers of the instructionsThe first instruction (e-Directorate) maintains a separate scope, while the second auxiliary instruction (one-direction) is a reference of the first and sets the property through the defined functions on the first instructions. ):

  
  • DOCTYPE html> ng-app = "plunker"> meta charset = "utf-8" /> Gt; & gt; Title & gt; Anguljes Plunker & lt; / title & gt; & lt; script & gt; document.write ('& lt; base href =' 'document.location +' "/ & gt; '); & lt; / scripts & gt; & Lt; Link rel = "stylesheet" href = "style.css" /> & Lt; Script Data - rp = "angular.js@1.2.x" src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js" Data-save = "1.2" 16 "& gt; & Lt; / Script & gt; & Lt; Script src = "app.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body ng-controller = "MainCtrl" & gt; & Lt; Div e-directive config = "parentconfig" a-directive & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;

    and Javascript:

      var app = angular Module ('plunker', []); App.controller ('MainCtrl', function ($ scope) {$ scope.parentConfig = {};}); App.controller ('ECtrl', function ($ scope) {this.setProp = function (newProp) {$ scope.config.prop = newProp;} scope. $ Watch ('config', function (newProp, oldProp) {Console .log (old prop, newprap);});}); App.directive ('e directive', function () {return: restricted: 'a', scope: {config: '='}, controller: 'ECtrl', link: function (region, element, ethers) {scope. config .prop = "abc";}};}); App.directive ("airective", function ()) {ctrl.setProp ("def")}} {Return: {A: A: Required: 'e directive', link: function (area, element, etter, CTL) {};});    

  • Comments

    Popular posts from this blog

    Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

    multithreading - PhantomJS-Node in a for Loop -

    c++ - MATLAB .m file to .mex file using Matlab Compiler -