javascript - AngularJS Routed Page Not Showing -


so quick question i've been looking @ code awhile cannot find why, gives me output on page

partials/view1.html 

i'm not trying post here whenever run small issue has been baffling me awhile now, , no errors on console. run code http://plnkr.co/edit/sn9tagvbodx3mkrxatiu?p=preview, mentioned on post , works fine, don't right output this. following index.html (the main page)

<!doctype html> <html ng-app="demoapp"> <head> </head>  <body>     <div ng-view></div>           <script src="angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>     <script src="scripts.js"></script> </body> 

my script likes:

var demoapp = angular.module('demoapp', ['ngroute']);              demoapp.config(function($routeprovider) {             $routeprovider                 .when('/',                       {                         controller: 'simplecontroller',                         template: 'partials/view1.html'                       })                 .when('/partial2',                      {                         controller: 'simplecontroller',                         template: 'partials/view2.html'                     })                 .otherwise({ redirectto: '/'});          } );      demoapp.controller('simplecontroller', function ($scope) {         $scope.customers = [             {name: 'john smith', city: 'phoenix'},             {name: 'jane doe', city: 'new york'},             {name: 'john doe', city: 'san francisco'}         ];          $scope.addcustomer = function() {             $scope.customers.push({                  name: $scope.newcustomer.name,                 city: $scope.newcustomer.city              });         }     }); 

and don't supposed shown view1.html, showed above. code

<div class="container"> <h2>view 1</h2> name:  <br> <input type="text" ng-model="filter.name"> <br> <ul>     <li ng-repeat="cust in customers | filter:filter.name | orderby: 'city'">{{ cust.name }} - {{ cust.city }}</li> </ul>  <br> customer name: <br> <input type="text" ng-model="newcustomer.name"> customer city: <br> <input type="text" ng-model="newcustomer.city"> <br> <button ng-click="addcustomer()">add customer</button> <br> <a href="#/view2">view 2</a>  </div> 

you should using templateurl instead of template:

.when('/partial2',    {      controller: 'simplecontroller',      templateurl: 'partials/view2.html'    }) 

https://docs.angularjs.org/api/ngroute/provider/$routeprovider


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -