我尝试将对象从index.html控制器(signupCtrl)传递给connexion.html(控制器:affCtrl)并使用工厂以connexion.html的形式显示对象,我创建了这个plunker
这是包含两个控制器的script.js文件
'use strict'
var demoApp = angular.module('demoApp', []);
demoApp.controller('signupCtrl', function($scope, $rootScope, per) {
$scope.envoie = function (user) {
per = user;
console.log(per);
window.location="connexion.html"
};
});
demoApp.controller('affCtrl', function($rootScope, per) {
$rootScope.per = per;
});
工厂:
demoApp.factory("per",function() {
return {
"name":"",
"password":"",
}
});