Last active
December 16, 2015 18:49
-
-
Save liorkesos/5480383 to your computer and use it in GitHub Desktop.
The wierd issue here is that stuff that I put on the scope within the success - doesn't work. - actually nothing in the update function persists in scope.
I see that the request is fine because I see the console.log at line 36. The controller is defined in index.html that ng-includes profile.html
For instance the $scope.authenticated is not set …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DashboardController($scope, $http, $location) { | |
$scope.list = ['ש.עבודה','משימות','הודעות','מערכת','מבחנים']; | |
$scope.test = ['1','2','3','4']; | |
$scope.dis='none'; | |
$scope.start=function () { | |
console.log("hello"); | |
} | |
$scope.show=function (item) { | |
if (item=='מערכת') { | |
$scope.timetable=['ראשון','שני','שלישי','רביעי','חמישי','שישי']; | |
} | |
else { | |
$scope.timetable=null; | |
} | |
$scope.item=item; | |
} | |
$scope.doBig = function(i){ | |
/*alert(i);*/ | |
$scope.side=i; | |
$scope.dis='block'; | |
} | |
$scope.master= {}; | |
$scope.update = function(userpass) { | |
console.log(userpass); | |
//$scope.master= angular.copy(user); | |
$http.post("/0.1/login",userpass) | |
.success(function(data, status, headers, config) { | |
$scope.user.password = null; | |
if (data.success) { | |
console.log(data.user); | |
$scope.user = data.user; | |
$scope.authenticated = 'zebra'; | |
$scope.err = false; | |
$location.path("/dashboard"); | |
} else { | |
$scope.err = data.errDesc; | |
$scope.authenticated = false; | |
} | |
$scope.$apply(); | |
}).error(function(data, status, headers, config) { | |
$scope.user.password = null; | |
$scope.status = status; | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app="DashboardApp" data-ng-controller="DashboardController" > | |
<div data-ng-include="'views/dashboard/profile.html'" ></div> | |
<div data-ng-include="'views/dashboard/dayOrganizer.html'"></div> | |
<div data-ng-include="'views/dashboard/navigation.html'"></div> | |
<div data-ng-include="'views/dashboard/navResult.html'"></div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="profile" class="x"> | |
<div class="logo"><img src="http://dev-v2.sefereshet.org.il/images/logo-daf-talmid.png"/></div> | |
{{user.username}} | |
{{authenticated}} | |
<div class="date"> | |
<h4><div class="kav">יום שלישי </div>17/4/2013</h4> | |
<h5>תאריך עברי</h5> | |
</div> | |
<div class="student_profile"> | |
<div class="profile_pic"><img src="" /></div> | |
<h4 class="name">סשה גור</h4> | |
<h5 class="class_info">א3 <span class="normal_font">בי"ס האלה</span></h5> | |
<h5 class="teather_name">מחנך: <span class="normal_font">נורית גל</span></h5> | |
</div> | |
</div> |
I did but now I get $digest is in allready in progress errors.
if you use Angular's providers (i.e $http) you should probably not use $apply.
And usually its best (practice) to not use the $http provider from the controller, but from a service/factory
Please put it on JsFiddle or jsBin
Lior, i would put the response data parameter inside - $scope.responseData
and watch it with - $scope.$watch
the watch third parameter should be true btw. (if its an object properties that are changed..)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lior, Add $scope.$apply() at the end of the success callback. That should update the scope