angularjs - How can I inherit complex properties from the parent scope into my directive's isolated scope -
AngularJS (and related) After reviewing other stack overflow questions about separate scops within documentation and instructions, I Still, I am a little confused, why can not I make a bi-directional binding between the area of the parents and the different scope, where the parent's property is an object and there is no specialty? Should I just use the desired property from the The relative is Bela. HTML: Javascript: For instructions on using a separate scope, Features To specify which parent will have to separate the child's area to separate the opportunity properties, '=' provides two-way binding '@' "one-way wire" provided Does 'Amp;' Provides the only expression. To access your instructions (double-sided binding) on the parent property property property, It may be more instructive to use different names: then in your instructions: The isolated scops are not basically deprived of parents' territory, hence its parents Do not have access to properties (if '@' or '=' or '& amp;' is used). Using area? $ Parent? Thanks in advance for your help it looks wrong.
& lt; Div ng-app = "myApp" & gt; & Lt; Div ng-controller = "myCtrl" & gt; & Lt; Div my-directive & gt; {{Test.name}} & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;
var myApp = angular.module ('myApp', []); MyApp.controller ('myCtrl', function ($ scope) {$ scope.test = {name: "name", value: "value"};}); MyApp.directive ("myDirective", function () {Return: true, restrict: 'A', scope: {test: '='}, template: '
test , use this HTML:
< Code> & lt; Div my-directive test = "test" & gt; & Lt; / Div & gt;
& lt; Div my-directive somewhat-obj-prop = "test" & gt; & Lt; / Div & gt;
area: {localDirProp: '= someObjProp'}, template: '& lt; Div ... & gt; Value = {{LocalDirProp}} ... ',
$ parent is still a way to reach the parent area, but not through prototype inheritance. Angular makes special
$ parent property on this scope generally (i.e. best practice), it should not be used.
Comments
Post a Comment