angularjs - Angular UI-Router very basic example is not working ? Please see full code on plunker -


angular ui-router not working? please see code on plunker.

i trying run basic routing example in angular js. welcomeview.html not appearing on page.

(function() {   "use strict"   var app = angular.module("plunker", ["ui.router"]);    app.config(["$stateprovider", "$urlrouterprovider",     function($stateprovider, $urlrouterprovider) {       $urlrouterprovider.otherwise("/");       $stateprovider         .state("home", {           url: "/",           templateurl: "welcomeview.html"         })     }   ]); }()); 

there updated , working version

firstly need add reference app.js our module

<head>   ...   <script src="app.js"></script> // missing   <script src="script.js"></script>   </head> 

also, should not use ng-controller, not need ui-router

//<body ng-controller="mainctrl"> <body> 

the app.js on other hand, should contain controller : "..."

  $stateprovider     .state("home", {       url: "/",       templateurl: "welcomeview.html",       // declare here       controller: "mainctrl",     }) 

then, in script.js, cannot redefine module plunker (using setter) - have take (using getter)

// redefine app.js stuff //var app = angular.module('plunker', []); // getter module var app = angular.module('plunker');  app.controller('mainctrl', function($scope) {   $scope.name = 'world';  }); 

check in action here


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -