Just delving into the world of angularJS for the first time. I've set up the routing service, which involves having a div with routing that calls in a template containing HTML code. I also have a range of regular JavaScript functions necessary for the code in the template to display correctly (such as slideshows and various other components).
However, when I run the code, I encounter null errors indicating that my JS functions are unable to locate certain elements. This could be due to them not being able to access the code in the ng-view or the template not loading before they are executed.
I did manage to get it working by placing all of my JavaScript functions in the controller assigned to that template. But I suspect this may not be the correct approach. What is the proper method to ensure everything works smoothly? Thank you.
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider){
$routeProvider
.when("/",{
templateUrl:"about.html",
controller:"aboutCtrl"
})
.when("/aboutus", {
templateUrl:"entertainment.html"
})
});
app.controller('aboutCtrl', function($scope){
// Regular JavaScript/jQuery code placed here to ensure functionality
});