0

I am having two controllers -

Parent Controller

dashboardApp.controller("parentController", ['$scope', function($scope){
    $scope.rootRules = {blackRule: "", blueRule: "", greenRule: "", yellowRule: "", orangeRule: "", redRule: ""};

So as you can see it has a variable called rootRules which I am updating in the child controller as -

Child Controller

            var color = $scope.color + "Rule";
            $scope.rootRules[color] = ruleString;
            console.log($scope.rootRules);

So it works when rootRules is having "" for that color however when the rootRules have some string stored in it for that color then I am unable to see the updates on screen for this code. Please let me know if full code required.

Thanks in advance.

codeomnitrix
  • 4,179
  • 19
  • 66
  • 102

1 Answers1

0

You can access and modify the parent scope like this:

$scope.$parent.rootRules[color] = ruleString;

More in depth answer here: https://stackoverflow.com/a/21454647/3858736

Community
  • 1
  • 1
Matt
  • 276
  • 1
  • 7