1
我正在使用angularJS Flash消息來顯示錯誤消息,但在控制檯中獲取此錯誤。我曾嘗試過angularjs以前的版本,但無法解決這個問題。Flash消息在angularJS中不起作用
angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=MainApp&p1=Error%3A…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A20%3A274)
at angular.js:38
at angular.js:4458
at n (angular.js:340)
at g (angular.js:4419)
at eb (angular.js:4344)
at c (angular.js:1676)
at yc (angular.js:1697)
at Zd (angular.js:1591)
at angular.js:29013
at HTMLDocument.b (angular.js:3057)
角碼
var app = angular.module('MainApp',["ngFlash"]);
app.controller('Appctrl',['Flash','$scope','$http',function($scope,$http,Flash) {
$scope.RegisterUser = function(){
if($scope.register.username == undefined || $scope.register.email == undefined || $scope.register.password == undefined){
var message = 'please enter correct information.';
Flash.create('success', message);
}
}
}])
HTML:
<!doctype html>
<html>
<head>
<title>DNS </title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Angular Material style sheet -->
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
<!-- Angular Material requires Angular.js Libraries -->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
<!-- Angular Material Library -->
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>
<!-- bootstrap link-->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="/controller/controller.js"></script>
</head>
<body ng-app="MainApp" ng-controller="Appctrl" >
<div class="container" >
<h1><small>Welcome to domains360.net</small></h1>
</div>
<div class="container">
<flash-message duration="5000" show-close="true" on-dismiss="myCallback(flash);" ></flash-message>
<h3><small>Register here</small></h3>
<form method="post">
<label for="name" >User Name</label>
<input type="text" ng-model="register.username" name="username" class="form-control">
<label for="email" >Email:</label>
<input type="email" name="email" ng-model="register.email" class="form-control">
<label for="password">Password</label>
<input type="password" name="password" ng-model="register.password" class="form-control"/>
<input type="button" ng-click="RegisterUser();" class="form-control btn btn-success" value="Sign up">
</form>
</div>
<div class="container">
<h3><small>Login Here</small></h3>
<form method="post" action="/user/authenticate">
<label for="email" >Email:</label>
<input type="email" name="email" class="form-control">
<label for="password">Password</label>
<input type="password" name="password" class="form-control"/>
<div class="alert-danger"><%=messages%></div>
<input type="submit" class="form-control btn btn-success " value="Sign In">
</form>
</div>
</body>
</html>
我在哪裏得到錯誤或者我錯了,請讓我知道。 謝謝。
它看起來並不像你有''
你必須安裝插件才能使用它的功能。欲瞭解更多信息https://github.com/sachinchoolur/angular-flash。另外改變你的控制器的順序
來源
2017-07-25 18:53:27 Vivz
這不起作用 –