我想使用$rootScope
, 和$root
angular2 中的值。我也很困惑如何在 angular2 中转换 angularjs 指令,如下所示。
.directive('thisDirective', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', function(evt){
var getMethods = {
get_link:function(){
var observer = {
override:true,
triggerIndex:0,
onLink:function(link){
scope.$root.getThisVal = false;
(scope.$$phase || scope.$digest());}
};
scope.$root.bitlyUrl = "";
scope.$root.modelFlags.share_window = scope.$root.modelFlags.steps_upload = scope.$root.getThisVal = true; $('.addthisbtn[datatitle=Email]').trigger('click',observer )
},
addthis_button:function(){
var observer = {
override:true,
triggerIndex:0
};
$('.addthis-btn[data-title=Email]').trigger('click',observer )
}
};
getMethods[attrs['thisDirective']]();
});
}
};
})