angular.module('myDirective, [])
.directive('myDirective', function() {
return {
restrict: 'E',
scope: {
selectObject: '='
},
link: function(scope, element, attrs, controllers) {
scope.selectObject = 'Result value';
};
});
<my-directive select-object="myVariableInControlle"></my-directive>
<div ng-contoller="parentController">
<div ng-contoller="childController">
<!--Невозможно понять в каком контроллере находиться test-->
{{test}}
</div>
</div>
<div ng-contoller="parentController as parent">
<div ng-contoller="childController as child">
<!--Видно откуда вызывается test-->
{{parent.test}}
</div>
</div>
app.directive("topscroll", function($timeout){
return {
restrict: "A",
scope:{
watchdata:"="
},
link: function(scope,element){
var el = element[0];
function scrollToTop(){
element.ready(function () {
el.scrollTop = 0;
});
}
scope.$watch("watchdata",function(){
scrollToTop();
},true);
}
};
});