javascript - angular-ui router With two html pages -


my project has file home, page1, page2. home page has different header layout rest of pages. so, separate html file. page1 , page 2 using ui routing load in content of page, header , footer same.

my question is: if on home page , click btn 1. how load in content of page1? (it load index.html, no content of btn1.)

i'm not sure if passing id index.js solution , i'm not sure how that. make more sense make entire thing spa?

my home.html buttons:

<a type="text/html" href="home.html"  class="button home_btn">home</a> <a type="text/html" href="index.html" class="button my_btn1">page1</a> <a type="text/html" href="index.html" class="button my_btn2">page2</a> 

my idex.html:

<body>     <div class="container" ng-app="app">       <header ng-include="'html/header.html'"></header>         <div ui-view></div>       <footer ng-include="'html/footer.html'"></footer>     </div>   </body>   <script src="vendors/angular/angular.js"></script>   <script src="vendors/angular-ui-router/release/angular-ui-router.js     </script>   <script src="scripts/index.js"></script> 

my header.html:

<div id="headerlinks">             <a type="text/html" href="home.html" class="button home_btn">home</a>             <a type="text/html" ui-sref="page1" class="button my_btn1">page1</a>             <a type="text/html" ui-sref="page2" class="button my_btn2">page2</a>         </div>     </div> 

my index.js:

    var app = angular.module('app', ['ui.router']);     app.config(['$urlrouterprovider', '$stateprovider', function($urlrouterprovider, $stateprovider) {         $urlrouterprovider.otherwise('/');         $stateprovider           .state('page1', {             url: 'page1',             templateurl: 'page1.html',             controller: 'page1ctrl'           })           .state('page2', {             url: 'page2',             templateurl: 'page2.html',             controller: 'page2ctrl'           })    }]) 

i"m kinda confused asking @ it. believe asking how build router multiple pages. got work. if doesn't help, i'll see if can find resource or explain better.

import angular-ui-router.

<script src="vendors/angular-ui-router/release/angular-ui-router.js" type="text/javascript"></script> 

this index.js file looks like. has multiply views allow different header or content or footer or whatever.

var app = angular.module('app', [   'ui.router',   'ctrls' ]);  app.config(['$urlrouterprovider', '$stateprovider', function($urlrouterprovider, $stateprovider, $state) {   $urlrouterprovider.otherwise('/');    $stateprovider   .state('home',{     url: '/home',     views: {       'header': {         templateurl: 'html/headerhome.html',         controller: 'headctrl'       },       'content': {         templateurl: 'home.html',         //controller: 'contentcontroller'        }     }   })   .state('page1', {     url: '/page1',     views: {       'header': {         templateurl: 'html/header.html',         controller: 'headctrl'       },      'content': {         templateurl: 'page1.html',         controller: 'page1ctrl'       }     }   })   .state('page2', {     url: '/page1',     views:{       'header':{         templateurl: 'html/header.html',         controller: 'headctrl'       },       'content':{         templateurl: 'page2.html',         controller: 'page2ctrl'       }     }   }) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -