hey answer me wrecking head.
i getting error stating controller not function , got defined. understand can't see why.
<!doctype html> <html ng-app="kachicode"> <head lang="en"> <meta charset="utf-8"> <title>angularjs gmail</title> <script src="node_modules/angular/angular.js"></script> <script src="routectrl.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js"></script> <script src="node_modules/angular-route/angular-route.js"></script> <script src="app/config/route.js"></script> </head> <body id="backimg"> <div ui-view></div> </body> </html>
so page , routing working fine. problem in routectrl.js file saying function not defined:
var app = angular.module('kachicode', []); app.controller('indexctrl', function indexctrl($scope){ $scope.greeting ="hey seam"; $scope.goto = function() { console.log("clicking"); } });
this home file being loaded in uiview
<div ng-controller="indexctrl ctrl"> {{ctrl.greeting}} </div> angular.module('kachicode', ['ui.router']) .config(function ($stateprovider, $urlrouterprovider){ 'use strict'; $urlrouterprovider.otherwise("/"); $stateprovider .state('home', { url: '/', templateurl: 'home.html' }) .state('about', { url: '/about', templateurl: 'kachicode/about.html' }) .state('contact', { url: '/contact', templateurl: 'kachicode/contact.html' }); });
this route file
ok no now. i've checked see loading file correctly , made sure attaching kachicode defined in ng-app = "kachicode". these common reasons problem per stackoverflow forums mine still isn't working. me , i'll know forever more how fix it?
thanks much
you defining app twice, once in routectrl.js:
var app = angular.module('kachicode', []);
and again in route.js:
angular.module('kachicode', ['ui.router'])
either remove second parameter route.js (and add dependency routectrl.js's app), or change setup
the solution, based on order of loading of scripts (first routectrl.js, route.js) in routectrl.js:
var app = angular.module('kachicode', ["ui.router]);
and in route.js:
angular.module('kachicode')
though make sure load in angular-ui-router before routectrl.js
Comments
Post a Comment