【发布时间】:2014-06-29 21:32:22
【问题描述】:
我有this jsfiddle。它无法识别控制器。我在创建 jsfiddles 时度过了一段糟糕的时光。我错过了什么?我可以通过完全移除模块并让控制器成为一个函数来使其工作。但这不是应用程序的编写方式,因此无济于事。
<div ng-app="myapp" ng-controller="ZootCtrl">
<button ng-model="model" ng-click="inc()">{{model.count}}</button>
</div>
// this is in the javascript pane
var app = angular.module('myapp', [])
.controller('ZootCtrl', [$scope, function ($scope) {
$scope.model = {
count: 0
};
$scope.inc = function () {
$scope.model.count += 1;
};
}]);
【问题讨论】: