I need help on moving controller from app.js to desired folder. My Folder structure look likes the blw
---app
--home
--home.html
--homecontroller.js
--about
--contact
--app.html
--app.js
---asset
---index.html
I have kept my controller source in my app.js. But i planned to move the specific controller into the corresponding root folder. Lets say i have home controller code in app.js. Now i want to move it to homecontroller.js which placed in home folder. I tried that. but it doesn't work for me. However it works when i keep that in app.js. Can you help me to move it to desired root.
my app.js is
var app = angular.module('TrailApp', ['ui.router'])
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home/part1');
$stateProvider
.state('base', {
abstract: true,
url: '',
templateUrl: 'app/app.html'
})
.state('home', {
url: '/home',
parent: 'base',
templateUrl: 'app/home/home.html',
controller: 'homectrl'
})
.state('home.part1', {
url: '/part1',
templateUrl: 'app/home/part1.html',
//controller: 'homectrl'
})
.state('home.part2', {
url: '/part2',
templateUrl: 'app/home/part2.html',
//controller: 'homectrl'
})
.state('about', {
url: '/about',
parent: 'base',
templateUrl: 'app/about/about.html',
//controller: 'aboutctrl'
})
});
//This below code should be moved to homecontroller.js
app.controller('homectrl', ['$scope', '$location', '$rootScope',
function($scope, $location, $rootScope) {
$scope.custom = false;
$scope.actionBtn = function(event) {
$scope.custom = true;
};
}
]);