나는 anglejs에서 전역 범위에 서버와 설정을 저장하려고합니다. 여러 모드, 즉 개발 모드와 생산 모드에서 앱을 실행합니다. 나는 내가 속한 모드에 따라 결정되는 소수의 외부 서비스와 상호 작용한다. expressjs (내 서버)에서 angularjs에 대한 나머지 호출을 통해 제공 할 수있다. 그들은 내 expressjs의 설정 파일에 저장됩니다.Angularjs에서 시작시 서비스 호출 방법
시작시 호출되는 컨트롤러 기능이 있습니까? 어떻게 그러한 함수를 작성해야합니까? 현재 내 디렉토리 구조는
내 디렉토리 구조입니다. 각도 js의 전역 범위 변수는 mudules 등의 시스템에서 액세스 할 수 있습니까? 위의 디렉토리에서 인증 할 수 있습니까?
나는 또한 당신이 바로 NG-응용 프로그램 선언에서 앱 컨트롤러를 만들고 거기에 모든 것을 처리 할 수있는 공공
//public/init.js
'use strict';
angular.element(document).ready(function() {
//Fixing facebook bug with redirect
if (window.location.hash === '#_=_') window.location.hash = '#!';
//Then init the app
angular.bootstrap(document, ['mean']);
});
// Dynamically add angular modules declared by packages
var packageModules = [];
for (var index in window.modules) {
angular.module(window.modules[index].module, window.modules[index].angularDependencies || []);
packageModules.push(window.modules[index].module);
}
// Default modules
var modules = ['ngCookies', 'ngResource', 'ui.bootstrap', 'ui.router', 'mean.system', 'mean.testcases','mean.testruns',
'mean.auth'];
modules = modules.concat(packageModules);
// Combined modules
angular.module('mean', modules);
server/controllers/index.js, server/views/index.html 및 public/services/Global.js에서 힌트를 얻으십시오. – Whisher