My html looks like this:
<body ng-app="customDirective"><div ng-controller="anController">
Date format: <input ng-model="fooData"> <hr/>
Current time is: <my-new-directive
foo-Attr="{{fooData}}"></my-new-directive></div></body></html>
I would like to update data inside of my created tag my-new-directive if a
scope property scope.fooData is changed.
So I have a scope property called fooData:
$scope.fooData = 'Hello World!:)';
and I am creating a directive:
(function(angular) {
'use strict';
angular.module('customDirective', [])
.controller('anController', ['$scope', function($scope) {
$scope.fooData = 'Hello World!:)';
}])
.directive('myNewDirective', [function() {
function link(scope, element, attrs) {
var format,
timeoutId;
function updateValue() {
element.text(format);
}
scope.$watch(scope.fooData, function(value) {
format = value;
updateValue();
});
}
return {
restrict: 'A',
link: link,
scope: {
fooAttr: '@'
}
};
}]);
document.createElement('my-new-directive');})(window.angular);
But if I write new values inside of input tag, then nothing occurs in my
new directive.
Any help would be greatly appreciated! I am using AngularJS 1.5.8.
--
You received this message because you are subscribed to the Google Groups
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.