AngularJS Router Nested views with Nested states

In this Post We Will Explain About is AngularJS Router Nested views with Nested states With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to AngularJS Nested views with Nested states using RoutingExample

In this post we will show you Best way to implement angularjs – ui router – nested views with shared controller, hear for Creating Nested States with AngularJS UI Routerwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  AngularJS ui router nested views - AngularJS nested directive controller example

Make a HTML file and define markup

  
    
    <title>infinityknow.com : - AngularJS - Nested views</title>
    
    <a href="http://jquery.js">http://jquery.js</a>
    <a href="http://angular.min.js">http://angular.min.js</a>
    <a href="http://angular-ui-router.min.js">http://angular-ui-router.min.js</a>
    <a href="http://ui-bootstrap-tpls.min.js">http://ui-bootstrap-tpls.min.js</a>
    <a href="http://bootstrap.min.js">http://bootstrap.min.js</a>
  
  


    <div class="container">
      <div class="row">
        <div class="col-sm-2"></div>         
        <div class="col-sm-10"></div>
      </div>
    
      <div class="pull-right">
          <div style="width: auto;margin-right:11px">status:</div>
          <strong style="width: auto"> </strong>
      </div>
    </div>

   
     <div class="alert alert-info">
        <h3><a>home</a></h3>
        <h3><a>second_level</a></h3>
        <h3><a>first_levels</a></h3>
     </div>
   
  
   
     <h3>home</h3>
     <div class="col-sm-6"></div>
     <div class="col-sm-6"></div>
   
  
   
   	<div class="alert alert-warning">
       <strong>second_level</strong>
       <h5><a>create new</a></h5>
       <h5><a>view list</a></h5>
      
       <div style="background:white">
           <div></div>   
       </div>
      
      </div>
   
  
   
        create new second_level
   
  
   
      <ul>
        <li>second_level 1</li>
        <li>second_level 2</li>
        <li>second_level 3</li>
      </ul>
   
  
   
      <div class="alert alert-success">
       <strong>first_levels</strong>
       <h5><a>create new</a></h5>
       <h5><a>view list</a></h5>
        
       <div style="background:white">
           <div></div>   
       </div>
        
      </div>
   
  
   
        create new first_level
   
  
   <!-- list first_levels -->
   
      <ul>
        <li>first_level 1</li>
        <li>first_level 2</li>
        <li>first_level 3</li>
      </ul>
   
   


Make a js file and define scripting

var liveApp = angular.module('liveApp', ['ui.router']);
liveApp.config(function ($stateProvider, $urlRouterProvider) {
        $urlRouterProvider.otherwise("/index");
        $stateProvider
        
            // index
            .state('index', {
                url: "/index",
                views: {
                    'menu-view': {
                       templateUrl:"menu.html"
                    },
                    'container-view': {
                     	templateUrl:"home.html"
                    },
                        '[email protected]' :{
                           templateUrl:"second_level.html"
                        },
                        '[email protected]' :{
                           templateUrl:"first_levels.html"
                        },
                   'status-view': {
                       template:"<p>index<p>"
                    },
                },
            })
         	
        	  // second_level
            .state('second_level', {
                url: "/second_level",	
                views: {
                    'menu-view': {
                       templateUrl:"menu.html"
                    },
                    'container-view': {
                     	templateUrl:"second_level.html"
                    },
                   'status-view': {
                       template:"<p>second_level<p>"
                    },
                },
            })
        
          	// second_level, create substate 
            .state('second_level.create', {
                url: "/create",	
                views: {
                    '[email protected]_level': {
                       templateUrl:"second_level.create.html"
                    },
                    '[email protected]': {
                       template:"<p>second_level.create<p>"
                    },
                },
            }) 
        
        		// second_level, list substate 
            .state('second_level.list', {
                url: "/list",	
                views: {
                    '[email protected]_level': {
                       templateUrl:"second_level.list.html"
                    },
                    '[email protected]': {
                       template:"<p>second_level.list<p>"
                    },
                },
            }) 
        
            // first_levels
            .state('first_levels', {
                url: "/first_levels",
                views: {
                    'menu-view': {
                       templateUrl:"menu.html"
                    },
                    'container-view': {
                     	templateUrl:"first_levels.html"
                    },
                   'status-view': {
                       template:"<p>first_levels<p>"
                    },
                },
            }) 
        
            // first_levels, create substate 
            .state('first_levels.create', {
                url: "/create",	
                views: {
                    '[email protected]_levels': {
                       templateUrl:"first_levels.create.html"
                    },
                   '[email protected]': {
                       template:"<p>first_levels.create<p>"
                    },
                },
            }) 
        
        		// first_levels, list substate 
            .state('first_levels.list', {
                url: "/list",	
                views: {
                    '[email protected]_levels': {
                       templateUrl:"first_levels.list.html"
                    },
                   'status-vie[email protected]': {
                       template:"<p>first_levels.list<p>"
                    },
                },
            }) 
    });

Example

READ :  Flowroute SMS API using Yii 1 with PHP

I hope you have Got What is AngularJS UI-Router Nested Views And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.