javascript - Angularjs custom directive scope:true change it's parent scope -
i trying write 1 custom directive , put scope:true.as per knowledge should take parent scope , when change in model should change it's internal scope only. in below example find when ever change directive parent changed. can please tell me reason behind it.
html
<div class="container" ng-app="mymodule" ng-controller="maincontroll"> <div>lorem ipsum dolor sit amet, consectetur adipisicing elit. exercitationem harum numquam odio, tenetur earum deleniti culpa recusandae? temporibus expedita, porro numquam @ voluptas aspernatur nemo veniam nam, vel assumenda placeat!</div>{{text}}<br/> <input type="text" class="form-control" id="exampleinputemail1" placeholder="email" ng-model="text"> <firstdir></firstdir> </div>
javascript
var app = angular.module("mymodule",[]); app.controller("maincontroll",function($scope){ $scope.text = "content controller"; }); app.directive("firstdir",function(){ return{ restrict:"eacm", replace:"true", scope:"true", template:'<p>{{text}}<br/><input type="text" class="form-control" id="exampleinputemail1" placeholder="email" ng-model = "text"></p>' } })
the sample can find here
thank in advance
in code have provided scope assigned string "true" should boolean true
app.directive("firstdir",function(){ return{ restrict:"eacm", replace:"true", scope: true, template:'<p>{{text}}<br/><input type="text" class="form-control" id="exampleinputemail1" placeholder="email" ng-model = "text"></p>'}})
Comments
Post a Comment