【发布时间】:2014-07-19 13:12:34
【问题描述】:
当我对正在构建的基于 Angular 的应用程序运行 jSLint 时,我收到“意外的 '$scope'”错误。
以下是导致错误的代码的简化版本。您可以将代码输入jslint.com 网站以重现问题。
我不明白为什么第一个函数声明 (downloadFile) 不会导致错误,但第二个函数声明 (buildFile) 会导致错误。
/*jslint browser: true*/
/*global angular */
angular.module('testApp')
.controller('FileCtrl', ["$scope", function ($scope) {
"use strict";
$scope.downloadFile = function () {
window.location = '/path/to/file';
}
$scope.buildFile = function () {
}
}]);
【问题讨论】:
标签: javascript angularjs jslint