I have angular routes working, but I am getting stuck on particular piece I am not sure is possible. I want to use an external controller file.
Example of working code:
app.config(function($locationProvider, $routeProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl: '/AngularViews/Home/index.html'
}).when('/Login', {
templateUrl: 'AngularViews/Account/index.html',
controller: 'registerUser'
}).otherwise({ redirectTo: '/'});
});
app.controller('registerUser', function($scope) {
$scope.hello = 'test';
})
What I want to do is something more like so:
app.config(function($locationProvider, $routeProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl: '/AngularViews/Home/index.html'
}).when('/Login', {
templateUrl: 'AngularViews/Account/index.html',
}).otherwise({ redirectTo: '/'});
});
HTML for Template Login:
<script src="../../AngularScripts/Account/account.js"></script>
REGISTRATION
<div ng-controller="registerUser">
{{hello}}
</div>
Account.js file:
app.controller('registerUser', function($scope, data) {
$scope.hello = 'hello';
$scope.registerUser = function () {
var createData = {
"UserName": $scope.email,
"Password": $scope.password,
"ConfirmPassword": $scope.confirmpass
};
console.log(createData);
return createData;
};
})
When doing it the second way it keeps telling me registerUser is undefined because it can't find registerUser