Sharing Top Content from the Angular-sphere.

[SOLVED] Angular js not finding controller?- Angular.js Recipes

  • I am using angular js, I have written code in two different jsp files.showing two different views.
  • if I render single view it works fine.but if I render both views on same page I got this error

    Error: Argument ‘UserCtrl’ is not a function, got undefined

    the js code snippet in jsp’s is as follows.

  • in my first jsp file is

    and in the second one is

    I tried giving distinct names to modules but that too did not worked for me.any help is appreciated.

got it worked. It was due to the ng-app variable, i have binded it on both jsp pages.So now i binded it to the main body wrapper for both the jsp’s.


@angular_recipe: Angular js not finding controller? #Angular #AngularJS

I am using angular js, I have written code in two different jsp files.showing two different views. if I render single view it works fine.but if I render both views on same page I got this error

the js code snippet in jsp’s is as follows.

in my first jsp file is

// Bootstrap the Application var App = angular.module(‘module’, []); // Set up a controller and define a model App.controller(‘UserCtrl’, function($scope) { $scope.user = {}; jQuery.get(““, function(data) { angular.element(‘#user_detail’).scope().user = data; angular.element(‘#user_detail’).scope().$apply(); }, “json”); });

and in the second one is

// Bootstrap the Application var App = angular.module(‘module’, []); // Set up a controller and define a model App.controller(‘ProfileCtrl’, function($scope) { $scope.profile = {}; jQuery.get(““, function(data) { angular.element(‘#profile’).scope().profile = data; angular.element(‘#profile’).scope().$apply(); }, “json”); });

I tried giving distinct names to modules but that too did not worked for me.any help is appreciated. thanks !

got it worked. It was due to the ng-app variable, i have binded it on both jsp pages.So now i binded it to the main body wrapper for both the jsp’s.

This recipe can be found in it’s original form on Stack Over Flow.

Angular.js Recipes are structured in a Cookbook format featuring recipes that contain problem statements and solutions. A detailed explanation follows each problem statement of the recipe. This is usually contained within the solution; however, an optional discussion section can often contain other useful information helping to demonstrate how the solution works.

Angular.js is a JavaScript-based open-source front-end web application framework mainly maintained by Google and by a community of individuals and corporations to address many of the challenges encountered in developing single-page applications. The JavaScript components complement Apache Cordova, the framework used for developing cross-platform mobile apps. It aims to simplify both the development and the testing of such applications by providing a framework for client-side model–view–controller (MVC) and model–view–viewmodel (MVVM) architectures, along with components commonly used in rich Internet applications.

Lost? Begin by working through Angular’s Getting Started Guide to get yourself up-and-running.

[SOLVED] Angular js not finding controller?- Angular.js Recipes

Comments are closed, but trackbacks and pingbacks are open.