【发布时间】:2016-10-12 22:03:07
【问题描述】:
如果我点击一个链接,showOrHide 函数将返回 true。
我用 alert 和 console.log 函数测试了这段代码,它是有效的,但是如果我想在 ng-show 或 ng-hide 指令中测试这段代码,它就不起作用。我无法理解这个问题。
Sum: 函数返回 false,如果我点击某个链接返回 true 但是真假在ng-show里是不行的。
angular.js 文件
$scope.showOrHide = function (value) {
if (typeof value !== 'undefined')
{
return alert(true);
//console.log("true");
//return true;
}else {
return alert(false);
//console.log("false");
//return false;
}
};
$scope.projectId = $stateParams.projectId;
$scope.showOrHide($stateParams.projectId);
html 文件
<tr ng-repeat="n in data.projects track by $index"
ng-href="@{{n.id}}"
ui-sref="goTo({ projectId: n.id })">
<td>@{{n.project_code}}</td>
<td>@{{n.project_name}}</td>
<td class="text-primary">will add</td>
<td class="text-primary">will add</td>
<td class="text-primary">@{{n.status}}</td>
<td ng-show="showOrHide">test</td>
</tr>
【问题讨论】:
标签: javascript angularjs angularjs-directive ng-show