Angular: ng-model isolate simple 11896732
http://angularjs.org/
by mrajcok
HTML
<div ng-controller="MyCtrl">
parent scope: {{name}}
<myd ng-model="name"></myd>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
myApp.directive('myd', function($timeout) {
return {
restrict: 'E',
template: '<div>isolate scope: name={{name}} name2={{name2}}</div>',
require: 'ngModel',
scope: { name2: '=ngModel'},
link: function(scope, el, attrs, ctrl) {
console.log(scope.name2, scope);
$timeout(function() {
ctrl.$setViewValue('Mark');
}, 2000);
}
}
});
function MyCtrl($scope) {
$scope.name = 'Artem';
}