user3205859 user3205859 - 10 months ago 52
AngularJS Question

angular js the deugger doesn't get into the controller

when i debug my controller, it stuck at the initialization of the controller and doesn't get past it
here is the app

var app = angular.module('app', []);

and here is the controller and it's service

app.controller('UsersController', function ($scope, UsersService) {
$scope.User = [];
$scope.Image = [];
$scope.CV = [];
$scope.GetUserProfile = function (ID) {
UsersService.GetUserData(ID, function (Result) {
if (Result.success == true) {
$scope.User = Result.Content;

app.service('UsersService', function ($http) {
this.GetUserData = function (UserID,callback) {
var req = {
method: 'GET',
url: 'http://localhost:7598/tb/Profile/GetProfileByID',
headers: {
'Authorization': 'No Authentication'
params: {
'ID': UserID

and in html i reference the Angular js file and the App file and the Controller file

here is the HTML

<script src="~/Scripts/angular.min.js"></script>
<script src="~/ScriptControllers/MainApp.js"></script>
<script src="~/ScriptControllers/UsersController.js"></script>
<div class="card hovercard" ng-controller="UsersController">
<div class="card-background" ng-init="GetUserProfile(5)">

Answer Source

It seems that you're missing an ng-app directive in the html, according to the html and js code you've posted. The browser just parses the js code but does not execute it.

     <body ng-app="app"> ... </body>

Working example of your code: here