這裏是我的github帳戶的完整代碼。 https://github.com/mars76/angular-es6
我的切入點是app.js
import * as angular from 'angular';
import config from './app-config';
import run from './app-run-config';
import uiRouter from 'angular-ui-router';
import AppController from './app-controller';
import MyService from './my-service';
import * as serviceModule from './service';
import testDirective from './test-directive';
import muUtil from './util/util.js';
export default angular.module("my-app", ['ui.router','my-service-module','myUtil'])
.config(config)
.run(run)
.component('testDirective',testDirective())
.controller('appController', AppController).name;
這對模塊的依賴關係 「myUtil」
,這裏是該模塊
./util/的內容util.js
import * as utilRun from './util-run.js';
import * as MyService1 from './my-service1.js';
import * as MyService2 from './my-service2.js';
export default angular.module('myUtil', [])
.service('MyService1', MyService1)
.service('MyService2', MyService2)
.run(utilRun).name;
這裏是我的Se rvices
服務1:
export default class MyService1{
constructor(){
}
init(){
console.log('In MyService1()');
}
}
服務2:
export default class MyService2{
constructor(){
}
init(){
console.log('In MyService2()');
}
}
而且UTIL模塊
import MyService1 from './my-service1.js';
import MyService2 from './my-service2.js';
export default function utilRun(MyService1,MyService2){
MyService1.init();
MyService2.init();
}
utilRun.$inject =['MyService1','MyService2'];
「調用者」在哪裏定義? – azium
這就是角碼而不是我們的應用程序代碼。 –
角。js行4571方法名稱getService(serviceName,caller))我正在使用的角度版本是1.5.3 –