我有两个按钮。我想在按钮点击时调用装饰器功能..在另一个按钮上我想调用服务主要方法..
怎么可能。 我想如果用户点击它显示的第一个按钮
console.log('--- this os')
如果用户点击它显示的第二个按钮,我想要
console.log('this is name');
http://plnkr.co/edit/JPTtScno7Saru1GwwkUn?p=preview
//代码在这里
angular.module('app',[]).controller('cntrl',function(newservice,$scope){
$scope.callDecorator=function(){
newservice.getName();
}
$scope.withoutDecorator=function(){
newservice.getName();
}
}).service('newservice',function(){
this.getName=function(){
console.log('this is name');
}
}).decorator('newservice',function($delegate){
$delegate.getName=function(){
console.log('--- this os')
}
return $delegate
})