【发布时间】:2015-04-25 17:12:39
【问题描述】:
我有两个相同的应用程序(除了应用程序/控制器名称)彼此紧挨着。第一个按预期工作,第二个显然根本没有执行。
我的代码(jsfiddle):
<div ng-app="passwdtool" ng-controller="PasswordController">
Password: <input ng-model="pass" required type="text"><br>
<span>{{ hash }}</span><br>
</div>
<div ng-app="passwdtool2" ng-controller="PasswordController2">
Password: <input ng-model="pass" required type="text"><br>
<span>{{ hash }}</span><br>
</div>
angular.module('passwdtool', [])
.controller('PasswordController', ['$scope', function($scope) {
$scope.pass = "password";
$scope.hash = "a hash";
}]);
angular.module('passwdtool2', [])
.controller('PasswordController2', ['$scope', function($scope) {
$scope.pass = "password";
$scope.hash = "a hash";
}]);
输出:
密码:[
password]
哈希
密码:[]
{{ 哈希}}
发生了什么事?
【问题讨论】:
-
Angular 只启动第一个 ng-app。第二个应该手动启动
标签: javascript html angularjs web