其他如果和返回javascript
问题描述:
我正在同时学习Angular 1.5和js。我从notify.js中分配一些默认值。我有没有错误的代码,但我有一种感觉,如果可以以更好的方式完成。此外,只要我尝试并把回报,我会得到错误。有人能告诉我做最好的办法,如果其他人和回报去(底部或内联?)。我仍然很难结束函数和分号。我知道这些看起来很奇怪,但没有错误。其他如果和返回javascript
谢谢。
function NotificationService ($scope, $) {
var vm = this;
/**
* @see notifyjs.com
*/
vm.publish = function (type) {
if (type === 'info') {
$.notify.defaults({
scope: $scope,
className: 'info',
autoHide: true,
position: 'bottom'
});
}
else if (type === 'success') {
$.notify.defaults({
scope: $scope,
className: 'success',
autoHide: true,
position: 'bottom'
});
}
vm.publishNoClose = function() {
$.notify.defaults({
scope: $scope,
className: 'warn',
autoHide: true,
position: 'bottom'
});
};
vm.publishNoCloseAlert = function() {
$.notify.defaults({
scope: $scope,
className: 'error',
autoHide: false,
position: 'middle'
});
};
};
}
答
只要做到:
$.notify.defaults({
scope: $scope,
className: type,
autoHide: true,
position: 'bottom'
});
}
他们分享一切,但类名。
我明白了,每个人都会得到回报吗? – CB1111
你是什么意思的“每个”? – TheDude