I'm working on bringing together Angular 1.5 and UI Router using ES6 import module syntax with Babel & Webpack.
Here is an example from my app.js file:
'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'
})
});
In the login/login.ctrl.js file, I have:
'use strict';
export default app.controller("LoginCtrl", function() {
//code here
});
When I launched my app, I encountered this error message:
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.
Another question that arises is how to utilize the "controller: 'loginCtrl as login'" syntax with ES6 import/export?