Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use angular routing to nest 3 mvc razor models

I want to have a UsersAdmin view that has Account Registration, UserProfile class and a Identity Role class. I am using MVC5 with default Individual Authentication. I am using ui-router for my routing. I have seen many examples using a viewmodel to pass multiple models to a single cshtml view. But I am needing a more complex setup. I created a mock up of what I am looking for. What is the best way to do this. mockup

Here is what my setup looks like

ui-routing

 // Default route
    $urlRouterProvider.otherwise('/Document');

    // Application Routes States
    $stateProvider
      .state('app', {
          abstract: true,
          controller: "CoreController",
          resolve: {
              _assets: Route.require('icons', 'toaster', 'animate')
          }
      })
      .state('app.document', {
          url: '/Document',
          templateUrl: Route.base('Document/Index'),
          resolve: {}
      })
      .state('app.register', {
          url: '/Register',
          templateUrl: Route.base('Account/Register'),
          resolve: {}
      }).state('app.applicationUser', {
          url: '/ApplicationUser',
          templateUrl: Route.base('ApplicationUsers/Index'),
          resolve: {}
      }).state('app.role', {
           url: '/Role',
           templateUrl: Route.base('Role/Index'),
           resolve: {}
     }).state('app.roleCreate', {
           url: '/RoleCreate',
          templateUrl: Route.base('Role/Create'),
          resolve: {}
     }).state('app.userProfile', {
         url: '/UserProfile',
         templateUrl: Route.base('UserProfiles/Index'),
         resolve: {}
     }).state('app.userProfileCreate', {
         url: '/UserProfileCreate',
         templateUrl: Route.base('UserProfiles/Create'),
         resolve: {}
     }).state('app.login', {
         url: '/Login',
         templateUrl: Route.base('Account/Login'),
         resolve: {}
     });
 }

_Layout.cshtml

 <div ui-view class="app-container" ng-controller="CoreController">@RenderBody()</div>

Navigation

 <li>
   <a ui-sref="app.userProfile" title="Layouts" ripple="">
      <em class="sidebar-item-icon icon-pie-graph"></em>
         <span>User Profile</span>
   </a>
 </li>

I have no issue using modals for the Create,Details,Edit views if that is a easier solution. However I do not know how to pass the selected Id with its properties to the modal.

like image 598
texas697 Avatar asked Jul 16 '15 11:07

texas697


People also ask

What is the difference between routing in AngularJS and MVC?

AngularJS is a client-side page rendering framework. Routing in AngularJS is similar to MVC routing but MVC routing is server-side while the AngularJS routing is client-side routing. I have added some code to HomeController section.

What is the difference between home and routing in AngularJS?

Here, Home is the Controller name and Routing is the Controller action method or View name. Add the following code in "_Layout.cshtml" file. of AngularJS application. Also, I have added an Angular Library here. Routing in AngularJS is similar to MVC routing but MVC routing is server-side and AngularJS routing is client-side routing.

How do I use client side routing in angular?

Client Side Routing Using Angular In MVC. AngularJS supports a Single page application routing module called ngRoute. When a user requests a specific url, the routing engine fetches that url and renders the view based on the defined routing rules. AngularJS appends '/#/' to the url to redirect to a particular url using $location service.

What is ngroute in AngularJS?

AngularJS supports a Single page application routing module called ngRoute. When a user requests a specific url, the routing engine fetches that url and renders the view based on the defined routing rules. AngularJS appends '/#/' to the url to redirect to a particular url using $location service.


1 Answers

I believe that I answered your question to someone else. You want to gather information through the URL, right?

Using routes in AngularJS to gather data

like image 67
noahdotgansallo Avatar answered Sep 29 '22 11:09

noahdotgansallo