I am learning Angular. I am watching a 2 years old video, and I am trying to use route concept and using in view1.CShtml (Remember, its CShtml and not html, while in the video, he uses html).
I also find it wierd that Views path starts as ~Views/View1.cshtml (Fair enough I have it in Views folder) on contrary to Partial/View1 where the video demonstrator has. Now, I do not understand what is this "~" for when I have similar directory structure like demonstrator.
Also, sadly, the view1 is not loading :( What is the problem? Of course he use single module and controller, but I am trying to use dependent module also for my own learning....What's the problem here?
angular.module('App', ['myFirstApp']).controller('Fir', function ($scope) {
$scope.Customers = [
{ name: 'Kiam', city: 'Los Angeles' },
{ name: 'Se', city: 'Los Vegas' }
]
}).config(function ($routeProvider) {
$routeProvider
.when('/View1',
{
controller: 'Fir',
templateUrl: '~Views/View1.cshtml'
})
.when('/View2',
{
controller: 'First',
templateUrl: '~Views/View2.cshtml'
})
.otherwise({ redirectTo: '/View1' });
});
var temp = angular.module('myFirstApp', []);
var controllerCollection = {};
controllerCollection.First = function ($scope) {
$scope.Customers = [
{ name: 'Sita', city: 'Los Angeles' },
{ name: 'Ram', city: 'Los Vegas' },
]
};
temp.controller(controllerCollection);