1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
.controller('UserCtrl', function($scope, $rootScope, baasbox) { $scope.username = "unknown"; $scope.login = function() { BaasBox.login("test", "test") .done(function (user) { console.log("Logged in ", user.username); $scope.username = user.username; }) .fail(function (err) { console.log("error ", err); }) }; }) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
.controller('UserCtrl', function($scope, $rootScope, baasbox) { $scope.username = "unknown"; $scope.login = function() { console.log(baasbox); $http.post(baasbox.endPoint+'/login', { username: 'test', password: 'test', appcode: baasbox.appCode }, { 'X-BAASBOX-APPCODE: ': 'Basic '+baasbox.appCode, } ).success(function (json) { console.log(json.data.user); $scope.username=json.data.user.name; }); }; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
.controller('UserCtrl', function($scope, $rootScope, baasbox) { $scope.username = "unknown"; $scope.login = function() { BaasBox.login("test", "test") .done(function (user) { console.log("Logged in ", user.username); $scope.$apply(function(){ $scope.username = user.username; }); }) .fail(function (err) { console.log("error ", err); }) }; }) |