javascript - AngularJS control variable in custom directive template -


i made custom directive, , in template there variable ng-model="test",

in directive controller, how can make change on variable?

angular.module("mydirective", []).directive("ngtest", function(){     return {       restrict: "e",       scope: true,       template: "<input type='text' ng-model='test'>+       <button ng-click='change()'></button>",       controller: function ($scope, $element){         $scope.change = function(){           // no idea how control variable test here.           $scope.test = "123123123"; //this doesn't work. :(         }       }      }   }); 

here working plunker :)

app.directive("ngtest", function(){     return {       restrict: "e",       scope: true,       template: "<input type='text' ng-model='test'><button ng-click='change()'>click me</button>",       controller: function ($scope, $element){         $scope.change = function(){           // no idea how control variable test here.           $scope.test = "123123123"; //this doesn't work. :(         }       }      }   }); 

the problem find '+' in directive doesn't work need provide complete tempalte in same line or else use tempalteurl provide value it.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -