角:引导控制台给错误 [英] Angular : Bootstrap giving error in console
本文介绍了角:引导控制台给错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的code:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<script type="text/javascript" src="./angular.min.js"></script>
<script>
var app = angular.module('myApp', []);
var app1 = angular.module('myApp1', []);
app.controller('myCtrl', function($scope) {
$scope.firstName = "sparsh";
$scope.lastName = "khandelwal";
});
</script>
<title>Home Page</title>
</head>
<body>
<div ng-app="myApp" ng-init="name='Sparsh'">
<div ng-controller="myCtrl">{{firstName}}</div>
<p>
Name : <input type="text" ng-model="name">
</p>
<h1>Hello {{name}}</h1>
</div>
<div ng-app="myApp1" ng-init="names=['Jani','Hege','Kai']">
<ul>
<li ng-repeat="x in names">{{x}}</li>
</ul>
</div>
<script type="text/javascript">
angular.bootstrap(document, ['myApp1','myApp']);
</script>
</body>
</html>
虽然我可以看到预期的输出,但同时面临着控制台错误。
Although i can see the expected output, but at the same time facing console error.
下面是错误的描述
(当我点击网址)
它说,它已经自举,所以我删除.bootstrap功能对myApp,但没有工作。
it says it already bootstrapped so i remove the 'myApp' from .bootstrap function, but that didnt work.
请帮忙。
推荐答案
您正在做的两个 NG-应用
的声明和 angular.bootstrap(文件,['myApp1','对myApp']);
You are doing both ng-app
declarations and angular.bootstrap(document, ['myApp1','myApp']);
.
您需要选择只有一个方法,否则你得到的多个自举程序井descripted错误。
You need to choose only one method, otherwise you get the well descripted error of multiple bootstrapped applications.
这篇关于角:引导控制台给错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文