angularjs - basic else if and return javascript -


i learning angular 1.5 , js @ same time. assigning defaults notify.js. have code has no errors, have feeling else if done in better way. also, try , put returns in, errors. please show me best way if else , returns go (bottom or inline?). still have hard time ending functions , semicolons. know these odd but, no errors.

thank you.

 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'             });         };     }; }  

just do:

$.notify.defaults({                 scope: $scope,                 classname: type,                 autohide: true,                 position: 'bottom'             });         } 

they share class name.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -