angularjs - How to get the specific data in a response inside controller? -
i have code of login. getting data response hosting okay , ng-repeat in view once it's validate shows data. want make validation it, want specific data ex:username in data compare user input. when try specific entity username or password in controller, undefined variable shows alert figure selected. how able that? can me solve this.
$scope.login = function (user) { userfactory.login($scope.users).then(function (response) { console.log("student profile" + angular.tojson(response)); $scope.user = response.data; alert($scope.user.username); alert($scope.user.password); }, function (err) { var alertpopup = $ionicpopup.alert({ title: 'login failed!', template: 'please check credentials!' }); }); };
<button class="button button-block button-balanced" ng-click="login(user)">login</button> <div class="list card"> <div class="container"> <div ng-repeat="item in user"> id: {{item.user_id}} firstname: {{item.firstname}} lastname: {{item.lastname}} token: {{item.access_token}}</div> </div> </div>
Comments
Post a Comment