samedi 25 avril 2015

AngularJS: Second app in template doesn't work

I have two identical apps (apart from app/controller name) right after each other. The first one works as expected, the second one is apparently not executed at all.

My code (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";
}]);

The output:

Password: [password]
a hash
Password: []
{{ hash }}

What is going on?




Aucun commentaire:

Enregistrer un commentaire