The schoolyears state is initially active.
Whenever I attempt to activate the schoolyears.create state by clicking a button, I find that I need to perform this action TWICE for the create schoolyear view to be rendered. What am I doing incorrectly?
INDEX.HTML
// For brevity, navbar has been removed
<div ui-view="content" class="container body-content>
CONTENT
</div>
app.js
'use strict';
angular
.module('TGB', ['ui.router', 'ui.bootstrap'])
.run(['$rootScope', '$state', '$stateParams',
function ($rootScope, $state, $stateParams) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
}
])
.config(function ($stateProvider, $urlRouterProvider) {
//localStorageServiceProvider.setPrefix('TGB');
$urlRouterProvider.otherwise("schoolyears");
$stateProvider
.state('schoolyears', {
url: '/schoolyears',
views: {
'content@': {
templateUrl: "/js/schoolyears/schoolyears.html",
controller: 'SchoolyearsController'
}
}
})
.state('schoolyears.selected', {
url: '/:id'
})
.state('schoolyears.create', {
url: '/create',
views: {
'content@': {
templateUrl: '/js/schoolyears/createSchoolyear.html',
controller: 'CreateSchoolyearController'
}
}
})
});
SchoolyearsController.js
(function () {
'use strict';
angular
.module('TGB')
.controller('SchoolyearsController', SchoolyearsController);
function SchoolyearsController($scope, $state) {
$scope.schoolyears = [];
}
})();
CreateSchoolyearController.js
(function () {
'use strict';
angular
.module('TGB')
.controller('CreateSchoolyearController', CreateSchoolyearController);
function CreateSchoolyearController($scope, $state) {
}
})();