0

I want merge angular routing in asp .net mvc . can any one help me do this

enter image description here

my app file as above here i have area dashboard and dashboard mvc views and controllers. i want to create a menu as flows

  • dashboard
  • areaDashboard

html page

<ul>
    <li> <a href="#dashboard"> dashboard page </a></li>
    <li><a href="#Areas/areadashboard"> areaDashboard </a> </li>        
    </ul>

app.js file

 var app = angular.module('myApp' , ['ngRoute']);
    app.app.config(function ($routeProvider) {
    $routeProvider
        .when('/dashboard1', {
            templateUrl: 'Dashboard1',
            controller: 'dashCtrl'
        })
        .when('/area1/area1dashboard', {
            templateUrl: 'Area1/Area1Dashboard',
            controller: 'areaDashCtrl'
        })
        .otherwise({
            redirectTo: ''
        });  }).controller('dashCtrl' , function($scope){
 $scope.message =" this is dashboard controller";
}).controller('areaDashCtrl' , function($scope){
 $scope.message =" this is area dashboardcontroller";
});

dashboard/index.cshtml

<script type="text/ng-template"  id="Dashboard1">
<div ng-controller="dashCtrl">
{{message}}
</div>

area1/area1Dashboard/index.cshtml file

 <script type="text/ng-template" id="Area1/Area1Dashboard">
    <div ng-controller="areaDashCtrl">
    {{message}}
    </div>
</script>

i'm getting error like this

Error: [ng:areq] http://errors.angularjs.org/1.4.5/ng/areq?p0=dashCtrl&p1=not%20aNaNunction%2C%20got%20undefined
at Error (native)
at http://localhost:3376/Scripts/angular.min.js:6:416
at pb (http://localhost:3376/Scripts/angular.min.js:22:41)
at Sa (http://localhost:3376/Scripts/angular.min.js:22:128)
at http://localhost:3376/Scripts/angular.min.js:80:25
at link (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular-route.min.js:7:180)
at $ (http://localhost:3376/Scripts/angular.min.js:73:46)
at L (http://localhost:3376/Scripts/angular.min.js:61:495)
at g (http://localhost:3376/Scripts/angular.min.js:54:326)
at http://localhost:3376/Scripts/angular.min.js:53:388(anonymous function) @ angular.min.js:107(anonymous function) @ angular.min.js:80$ @ angular.min.js:73L @ angular.min.js:61g @ angular.min.js:54(anonymous function) @ angular.min.js:53(anonymous function) @ angular.min.js:55m @ angular.min.js:60v @ angular-route.min.js:6m.$broadcast @ angular.min.js:135(anonymous function) @ angular-route.min.js:11(anonymous function) @ angular.min.js:118m.$eval @ angular.min.js:132m.$digest @ angular.min.js:129m.$apply @ angular.min.js:133g @ angular.min.js:87L @ angular.min.js:91A.onload @ angular.min.js:92
2
  • Do you have the app declared such as <html data-ng-app="myApp">? May be basic, but I can't see the declare from the code you have given. Commented Oct 5, 2015 at 4:08
  • Also, here is a great read on using the two together. codeproject.com/Articles/806029/…. Commented Oct 5, 2015 at 4:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.