Html文件
<!DOCTYPE html>
<html >
<head>
<title>Angular JS Demo</title>
<script src="scripts/angular.min.js"></script>
<script src="scripts/Script_1.js"></script>
<meta charset="utf-8" />
</head>
<body>
<div ng-app="HelloWorldApp" ng-controller="HelloWorldController">
Message: {{ greeting }}
</div>
<div id="class2" ng-controller="HelloWorldController1">
Message: {{ message }}
</div>
</body>
</html>Script_1.js
/// <reference path="angular.min.js" />
angular.module('HelloWorldApp', []).controller("HelloWorldController", function ($scope) {
$scope.greeting = "Hello World";
});
angular.module('HelloWorldApp1',[]).controller("HelloWorldController1",function ($scope) {
$scope.message = "Hello World";
});
angular.bootstrap(document.getElementById('class2'), ['HelloWorldApp1']);
The output is
Message: Hello World
Message: {{ message }}尽管我使用了angular.bootstrap(document.getElementById('class2',HelloWorldApp1);为什么它不能引导?我是第一次接触这个无关紧要的js,我是否遗漏了任何库?我被卡住了here.Pls救救我。
谢谢
发布于 2016-08-03 00:51:16
试试这个:
<!DOCTYPE html>
<html >
<head>
<title>Angular JS Demo</title>
<script src="scripts/angular.min.js"></script>
<script src="scripts/Script_1.js"></script>
<meta charset="utf-8" />
</head>
<body>
<div ng-app="HelloWorldApp" ng-controller="HelloWorldController">
Message: {{ greeting }}
</div>
<div id="class2"ng-app="HelloWorldApp1" ng-controller="HelloWorldController1">
Message: {{ message }}
</div>
</body>
</html>https://stackoverflow.com/questions/38725868
复制相似问题