我正在关注这个 AngularJS+ASP.NET 教程,他们使用了$scope,但我试图用新语法替换过时的用法controller,如这个问题中所述:“AngularJs“控制器作为”语法 - 澄清?”
我所做的目前不起作用。页面在函数$http.get内部调用nextQuestion(),但视图保持不变,只有标题"loading question..."。
我的代码:
JS http://pastebin.com/RfngRuZD
var app = angular.module('QuizApp', [])
app.controller('QuizCtrl', ['$http', function ($http) {
this.answered = false;
this.title = "loading question...";
this.options = [];
this.correctAnswer = false;
this.working = false;
this.answer = function () {
return this.correctAnswer ? 'correct' : 'incorrect';
};
// GET
this.nextQuestion = function () {
this.working = true;
this.answered = false;
this.title = "loading question...";
this.options = …Run Code Online (Sandbox Code Playgroud)