AngularJS - 获取数据库数据(在 js 中)/使用 ng-show(在 html 中)
AngularJS - get DB data(in js) / use ng-show(in html)
我正在尝试从我的数据库中获取日期。对于数据,我想使用 ng-show。
在我的 js 文件中:
httpq.post('/data/instructor.asmx/PasswordAgain', postData)
.then(function(data) {
$scope.informs = JSON.parse(data.d.result).Table;
if ($scope.informs.length > 0) {
$scope.Ins_Checking = $scope.informs[0];
}
})
.catch(function(data, status) {
$.showToast('error', $filter('translate')('MSG.ERROR'));
})
.finally(function() {
console.log("finally finished1");
});
在我的html文件中(测试代码):
<div ng-repeat="inform in informs">
{{inform.Ins_Check}}
</div>
这是有效的。
问题:
<div ng-show="Ins_Check != 'O'">
Input Password : <input type="password">
</div>
<div ng-show="Ins_Check == 'O'">
The password is Correct!
</div>
有DB数据(inform.Ins_Check),如果数据不是'O',显示Input Password代码。或者,如果数据是 'O',则显示 'The password is Correct!'.
我应该输入什么密码?
或者我应该使用其他功能?
ng-show
和 ng-hide
用于处理真值和假值。如果 Ins_Check
有布尔值那么你不需要与 0 或 1 比较。简单写 ng-show="Ins_Check"
和 ng-hide="!Ins_Check"
工作示例here
抱歉延迟回复。
您使用的代码是 ng-show 的正确代码。您正在检查的条件变量是错误的。
在你的js中,你使用了$scope.Ins_Checking
来赋值。但是在 ng-show 比较中,您使用的 Ins_Check
在您的示例中不可用。
所以尝试用 Ins_Checking
替换 Ins_Check
。我希望这有效。
我正在尝试从我的数据库中获取日期。对于数据,我想使用 ng-show。
在我的 js 文件中:
httpq.post('/data/instructor.asmx/PasswordAgain', postData)
.then(function(data) {
$scope.informs = JSON.parse(data.d.result).Table;
if ($scope.informs.length > 0) {
$scope.Ins_Checking = $scope.informs[0];
}
})
.catch(function(data, status) {
$.showToast('error', $filter('translate')('MSG.ERROR'));
})
.finally(function() {
console.log("finally finished1");
});
在我的html文件中(测试代码):
<div ng-repeat="inform in informs">
{{inform.Ins_Check}}
</div>
这是有效的。
问题:
<div ng-show="Ins_Check != 'O'">
Input Password : <input type="password">
</div>
<div ng-show="Ins_Check == 'O'">
The password is Correct!
</div>
有DB数据(inform.Ins_Check),如果数据不是'O',显示Input Password代码。或者,如果数据是 'O',则显示 'The password is Correct!'.
我应该输入什么密码?
或者我应该使用其他功能?
ng-show
和 ng-hide
用于处理真值和假值。如果 Ins_Check
有布尔值那么你不需要与 0 或 1 比较。简单写 ng-show="Ins_Check"
和 ng-hide="!Ins_Check"
工作示例here
抱歉延迟回复。
您使用的代码是 ng-show 的正确代码。您正在检查的条件变量是错误的。
在你的js中,你使用了$scope.Ins_Checking
来赋值。但是在 ng-show 比较中,您使用的 Ins_Check
在您的示例中不可用。
所以尝试用 Ins_Checking
替换 Ins_Check
。我希望这有效。