Mic*_*llo 1 javascript jslint angularjs
当我针对我正在构建的基于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 () {
}
}]);
Run Code Online (Sandbox Code Playgroud)
函数导致该错误后缺少分号
$scope.downloadFile = function () {
window.location = '/path/to/file';
}; //<-- add semicolon
$scope.buildFile = function () {
}; //<-- add semicolon
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1445 次 |
最近记录: |