I am trying to piece together a custom directive from several different articles and a couple Pluralsight videos.
I am moderately OK with MVC but completely new to angular.
I want my angular to call MVC controller. The controller return a partial. Then a custom angular directive insert into a div place holder the partial html.
I am however getting angular errors in the F12 console but not sure how to debug.
I have three components.
Index.cshtml
<div class="row">
<div class="col-md-3" ng-app="app-MainNav">
<div Dashboard-Main-Nav></div>
</div>
</div>
app-MainNav.js
(function ()
{
"use-strict";
angular.module("app-MainNav", [])
.directive("Dashboard-Main-Nav", function ($http)
{
return
{
restrict: "E",
link: function($scope, element)
{
$http.get("/Navigation/GetDashItems")
.success(function (data)
{
element.html(data);
});
}
};
});
})();
NavigationController.cs
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult GetDashItems()
{
var DashItems = _dashboardService.GetDashboardNavigation();
var results = Mapper.Map<IEnumerable<MLS_DashNav>>(DashItems);
return PartialView("~/Views/Navigation/_MainNav.cshtml");
}
I'm sure the problem is in my app-MainNav in how I am configuring the Angular App Directive.
The error is an Unexpected Token but again according to the tutorials I am pretty much following their example.
TIA