Angular playground
by Adambasszer
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<div ng-app="myApp">
<div ng-controller="myController">
<p ng-click="changeHELLO()">{{valami}}</p>
<xx valamike="ezazamaz"></xx>
</div>
</div>
JavaScript
angular.module("myApp", []);
angular.module("myApp").directive('xx', function () {
return {
restrict: 'E',
template: '<p>kkk</p>',
link: function postLink(scope, iElement, iAttrs) {
console.log("scope", scope);
console.log("iElement", iElement);
console.log("iAttrs", iAttrs);
scope.$watch("valami", function (newValue, oldValue) {
console.log("oldValue", oldValue);
console.log("newValue", newValue);
console.log("iElement", iElement);
});
}
};
});
angular.module("myApp").controller("myController", ["$scope", function ($scope) {
//console.log($scope);
$scope.valami = "HELLO";
$scope.changeHELLO = function () {
$scope.valami = "WELLHELLO";
};
}]);