我想在我的视图中显示 File "mygame1.py", line 38, in fight
elif fight_answer_y == "apologize":
UnboundLocalError: local variable 'fight_answer_y' referenced before assignment
和$scope.predicate
值(在$scope.reverse
标记中)。似乎使用<p>
表达式无效。
app.js:
{{ }}
HTML:
var app = angular.module('testApp', []);
app.controller('TestController', function($scope,$http ){
var vm = this;
vm.rezdata = [];
$http.get("some rest resource...")
.then(function(response) {
vm.rezdata = response.data;
$scope.predicate = 'username';
$scope.reverse = true;
});
});
答案 0 :(得分:1)
将ng-controller="TestController as test"
放在body
代码上。
此外,在使用控制器时使用controller as
语法时,控制器上下文(this
)内的值可通过别名test
在HTML上访问。 {{test.predicate}}; reverse = {{test.reverse}}
应该有用。
但从技术上讲,你不应该同时使用$scope
&amp;使用this
时,controller as
在同一个控制器中,这将再次造成混淆。因此,我建议您将$scope
更改为vm
。
<p>Sorting predicate {{predicate}}; reverse = {{reverse}}</p>
<table class="table table-striped" ng-controller="TestController as test">
...
</table>