I want help in AngularJs routing with MVC6 .cshtml views I create normal _layout for that's contains the application pattern. And I reader Index.csthml to _layout using ReanderBody function. Now I'm trying to add 'div' ng-view to render all other .csthml views using angularjs inside the Index.csthml but my code it's did not work.
AngularJs script that's I use as following:
angular.module('myApp', [])
.controller("MyController", function ($scope) {
$scope.message = "My Message Is Super Awesome";
});
angular.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
when('/route1', {
templateUrl: 'Home/BusinessLookup',
controller: 'BusinessLookupController'
}).
otherwise({
redirectTo: '/'
});
}]);
angular.controller('BusinessLookupController', function ($scope) {
$scope.message = 'This is Add new order screen';
});
And Index.csthml file look like:
<div>
<a href="Home#/route1">Test</a>
<div ng-app="myApp" ng-controller="MyController">
{{message}} <!--Here angular does not work-->
<div ng-view=""></div>
</div>
MVC routing setup:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}"
);
}