I am using ocLazyLoad library to lazy load angular javascript/html files and inject them to my module like this code snippet:
$routeProvider.when('/Home/Index', {
templateUrl: '/app/Index.html',
controller: 'IndexController',
resolve: {
deps: [
'$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load({}, {
name: 'mix',
files: [
'/app/IndexController.js'
]
});
}
]
}
});
With this approach I get static html file from file system. But what i want is set templateUrl:'/Home/Index' so Index action method in Home controller gets executed and razor renders specified .cshtml page then return html with angular directives.
Here is what i want to do. Razor view:
<p>
@foreach (var item in new List<int> { 1, 2, 3, 4, 5 })
{
@item
}
</p>
<div ng-controller="IndexController as vm">
<p>{{vm.text}}</p>
<p>{{3 + 3}}</p>
</div>
Response from server:
<p>12345</p>
<div ng-controller="IndexController as vm">
<p>{{vm.text}}</p>
<p>{{3 + 3}}</p>
</div>
Along with this html, lazy loaded IndexController.js Then angular will do its job.
Is it possible to do that?