Sat*_*eni 2 angularjs ecmascript-6
我试图将我的应用程序转换为使用ES6语法,在我的主模块中,我有配置和运行调用.
我改成了
import * as angular from 'angular';
import {config,run} from './my-config';
import MyAppController from './my-app-controller';
module.exports = angular.module("my-app", [])
.config(config)
.run(run)
.controller('myAppController', MyAppController)
Run Code Online (Sandbox Code Playgroud)
这是my-config.js
import MyService from './my-service';
export function config($compileProvider, $logProvider, localStorageServiceProvider,$stateProvider, $urlRouterProvider){
console.log('.config() : START ');
$compileProvider.debugInfoEnabled(true);
$logProvider.debugEnabled(true);
localStorageServiceProvider.setPrefix('myapp');
localStorageServiceProvider.setNotify(true, true);
$stateProvider.state('home', {
url: '/',
views: {
'main': {
controller: 'myAppCtrl',
templateUrl: 'app/home.tpl.html'
}
}
});
// handle routes here
$urlRouterProvider.otherwise('/');
}
config.$inject =['$compileProvider', '$logProvider', 'localStorageServiceProvider','$stateProvider', '$urlRouterProvider'];
export function run(MyService) {
console.log('.run() : ');
MyService.start();
}
run.$inject=['MyService'];
Run Code Online (Sandbox Code Playgroud)
并且没有调用配置和运行函数..
请让我知道我错过了什么
谢谢
我建议的事情很少:
import angular from 'angular';
export default angular
.module('app', [
//list of your modules
])
.config(config)
.run(run)
.name;
Run Code Online (Sandbox Code Playgroud)
配置我们使用:
export default function config(/* injectables here */) {
//Your code
}
Run Code Online (Sandbox Code Playgroud)
我们运行使用:
export default function run(/* injectables here */) {
/* @ngInject */
//Your code
}
Run Code Online (Sandbox Code Playgroud)
您可能不会像我们一样使用注射剂,或者使用/*@ngInject*/
| 归档时间: |
|
| 查看次数: |
4707 次 |
| 最近记录: |