angularjs - Accessing child scope -


I'm using ngTagsInput angular. My problem comes from trying to gain access to displayTags from an original root scope . It's not there. I want to get access to this because the user can add new tags to display the toggle which is working perfectly. I want to take those new tags and post them. How can I get access to displayTags in $ $ out of the loop?

This type of angular code:

  var app = angular.module ('recgroups', ['ngTagsInput']); App.directive ('group', function () {return {restrict: 'e', ​​scope: true, templateUrl: '../../Content/templates/RecruitingGroups/Group.html', link: function (scope, El) {// Remove group scope .removeGroup = function (group array, index) {groupArray.splice (index, 1);}}}}); App.directive ('rule' function () {return {restricted: 'e', ​​scope: true, templateUrl: '../../Content/templates/RecruitingGroups/Rule.html', link: function (scope, L) {scope.removeRule = function (ruleArray, index) {ruleArray.splice (index, 1);} scope.addTag = function () {scope $ parent.rule.Rules.push ({});}}}} }); App.directive ('tag', function () {return {restricted: 'e', ​​scope: true, templateUrl: '../../Content/templates/RecruitingGroups/Tag.html', controller: 'displayTags' , Link: function (scope, l) {scope.removeTag = function (tag array, index) {tagArray.splice (index, 1)}}}}}); App.controller ('displayTags', Function ($ Range, Data) {$ scope.displayTags = []; // to manipulate tags as appropriate tag models ($ scope.tag.TagIds! = Null) {$ Each ($ scope.tag.TagIds, function (scopeIndex, scopeValue) {$ .Every (data.Project.Tags, function (tagIndex, tagValue) {if (tagValue.Id == scopeValue) {$ scope.displayTags.push ({Id: tag value id, name: tag value .name, project id: tag value.projectId}}}}}}});}});   I am also submitting this image as a visual display of HTML: </ code> </ pre> <p> Image details Simplifying HTML is so much: </ p> <pre> <code> group ng-repeat =  gt; & lt; rules ng-repeat = "Rules in the Group Rule Rule." & Gt; & gt; Tag ng-Repeat = "Tag Rule in Rules">  input-ng-model = "displayTags" display-property = "name "& Gt; & lt; / tag Input & gt; & lt; / tag & gt; & lt; / rules & gt; & lt; / group & gt;    

scope: true , you can use scope: {displayTags : '=' // Bi-D (If parent = ^ model } is , You can use

  app.directive ('tag', function ()) {{return restricted: 'e', ​​scope: true, requires: "ngModel ", TemplateUrl: '../../Content/templates/RecruitingGroups/Tag.html', link: function (scope, L, attrs, ngModelCtrl) {Scope.doSomething = function () {ngModelCtrl. $ SetViewValue ('test'); // update model}}}});    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -