13
我想結合Angular 1.5,使用ES6導入模塊語法的UI路由器與Babel & Webpack。ES6導入語法與Angular 1.5 UI路由器
在我app.js我:
'use strict';
import angular from 'angular';
import uiRouter from 'angular-ui-router';
...
import LoginCtrl from './login/login.ctrl.js'
const app = angular.module("app", [
uiRouter,
...
])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('login', {
url: '/login',
templateUrl: '...',
controller: LoginCtrl,
controllerAs: 'login'
})
});
登陸/ login.ctrl.js我:
'use strict';
export default app.controller("LoginCtrl", function() {
//code here
});
當我開始我的應用我有以下錯誤信息:
ReferenceError: app is not defined
bundle.js:35422:2
Error: [$injector:modulerr] Failed to instantiate module app due to:
[$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it.
第二個問題。我如何使用控制器:「loginCtrl as login」語法與ES6導入/導出?