1
2 개의 다른 각도 응용 프로그램이있는 2 개의 다른 HTML 페이지가 있습니다. 한 페이지는 방문 페이지 용이고 다른 페이지는 홈페이지 용입니다. 첫 번째 페이지는 keycloak에 의해 렌더링되고 다른 페이지로 자동 리디렉션하고 app1 모듈을 두 번째 모듈에 삽입하므로 app1 세부 정보를 다시 사용할 수 있습니다.각 모듈을 다른 모듈로 방향 전환
var module = angular.module('product', []);
module.controller('GlobalCtrl', function(login) {
this.loginService = login;
});
module.factory('login', function($q, $rootScope) {
var keycloakAuth = new Keycloak('keycloak/keycloak.json');
var deferred = $q.defer();
keycloakAuth.init({onLoad: 'login-required'})
.success(function() {
console.log('Success', keycloakAuth);
deferred.resolve()
})
.error(function(err) {
console.error('Error', err, keycloakAuth);
deferred.reject(err);
});
keycloakAuth.ready = deferred.promise
.then(function() {
if (keycloakAuth.authenticated) {
keycloakAuth.loadUserProfile()
.success(function() {
console.log('User profile loaded');
$rootScope.$digest();
})
.error(function(err) {
console.log('Error loading user profile', err);
})
}
})
.finally(function() {
console.log('Finally');
$rootScope.$digest();
});
return keycloakAuth;
});
angular
.module('themesApp', [
'theme',
'theme.demos','product'
])
.config(['$provide', '$routeProvider', function($provide, $routeProvider) {
'use strict';
$routeProvider
.when('/newapp', {
templateUrl: 'views/index1.html',
resolve: {
loadCalendar: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([
'bower_components/fullcalendar/fullcalendar.js',
]);
}]
}
})
.when('/:templateFile', {
templateUrl: function(param) {
return 'views/' + param.templateFile + '.html';
}
})
.when('#', {
templateUrl: 'views/index1.html',
})
.otherwise({
redirectTo: '/newapp'
});
}]);
모듈을 다른 모듈로 리디렉션하려면 어떻게해야합니까?
당신은'ng-app = 'app1''으로 html을로드 한 다음'bootstrap' 메소드를 사용하여 다른 모듈을로드해야합니다 –