我是Angular js的新手。我正在尝试显示错误消息视图toaster()
。我在google上搜索,但未找到正确的结果。当我单击cancel()
按钮时,我将收到一条错误消息,提示未定义烤面包机。
HTML:<button class="btn btn-secondary" ng-show="editMode" ng-click="toggle_cancel()"> Cancel </button>
角Js:
$scope.toggle_erase = function(information){
toastr.toggle_erase('Are you sure want to delete ?')
$scope.hideDelay(3000):
}
最佳答案
您需要包含toastr.js和toastr.css文件。.请检查示例
// Code goes here
var app = angular.module('myapp',['toastr']);
app.controller('demo',function($scope,toastr){
$scope.toggle_remove = function(){
toastr.info('Hello!!');
toastr.refreshTimer(toastr, 3000);
}
});
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="https://npmcdn.com/angular-toastr/dist/angular-toastr.tpls.js"></script>
<link rel="stylesheet" href="https://npmcdn.com/angular-toastr/dist/angular-toastr.css" />
<script src="script.js"></script>
</head>
<div ng-app="myapp">
<div class="container" ng-controller="demo">
<button class="btn btn-secodary" ng-hide="editMode" ng-click="toggle_remove()"> Delete </button> <br/>
</div>
</div>
请通过http://angular-js.in/angular-toastr/
关于javascript - 还有其他定义 toastr 的方法吗,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46424096/