传递参数,封装函数

.run(['$rootScope', function ($rootScope) {
    $rootScope.alert = function (textContent(参数), toastClass, hideDelay) {
        $mdToast.show(
            $mdToast.simple()
                .textContent(textContent)(对应参数)
                .action('ok')
                .toastClass(toastClass)
               
.position('bottom right')
                .hideDelay(hideDelay || 3000)
        );
    }

 

self.send = function () {
    homeSvc.postHomeList(self.data.message).then(function (result) {
        $rootScope.alert('Send notifications successfully传递的值的内容 'toast-success')(第一个参数内容必传)
        //传输成功
$mdToast.show(
         $mdToast.simple()
            .textContent('Send notifications successfully')
            .action('ok')
            .toastClass('toast-success')(使用参数textContent,toastClass,hideDelay传递值中所需要的内容)
            
.position('bottom right')
            .hideDelay(3000)
         );

   
}, function (error) {
        $rootScope.alert('Failed to send notification', 'toast-error')
        //传输失败
   
})

}
posted @ 2017-04-26 15:08  芒果加冰  阅读(316)  评论(0编辑  收藏  举报