0

我想从 json 获取文件并将它们与从输入表单中获取的文本框进行比较,但我的代码似乎没有工作属性。我对 Angular 很陌生,这是我第一次尝试不适合工作的项目。

//这是JS文件

(function () {
    'use strict';

    angular.module('routerApp').controller('LoginCtrl', function ($http, $scope, $location) {

        $scope.loginUser = function () {
           $http.get('data.json').then(function(data){
               $scope.users = data;
               var usr = $scope.usr;
               var pwd = $scope.pwd;
               if(data.username == usr && data.password == pwd){
                   $location.path('/laptop');
               }
               else{
                   alert("Username or password is incorrect");
               }
           }); 
        };
    });
})();

当我单击登录按钮时,即使我没有输入任何内容,它也总是正确的

4

0 回答 0