【发布时间】:2015-10-30 10:21:47
【问题描述】:
我有一个控制器和两个模块,分为三个文件。当我在 Grunt 中运行 Jshint-Task 时,我总是收到错误消息,即缺少“use strict”语句。所以为了修复这个错误,我将语句包含在这三个文件中,但我仍然得到错误,我不明白为什么。由于我仍在学习 Angular 的基础知识,所以我不知道为什么会发生这种情况。
感谢您的回答!
控制器:
"use strict";
angular.module('calculatorApp').controller('HomeController', ['calculatorApp', function(){
var $this = this;
$this.test = function () {
$this.alert('test');
};
}]);
模块:
"use strict";
var calculatorApp = angular.module('calculatorApp', ['ngRoute']);
calculatorApp.config(function($routeProvider){
$routeProvider
.when('/', {
controller: 'HomeController',
templateUrl: 'home.tpl.html'
})
.otherwise({
redirectTo: '/'
})
});
【问题讨论】:
-
请发布示例代码
-
'使用严格';不适合你?请出示 plunker 或更多代码
-
我现在添加了一些代码示例。
标签: javascript angularjs jshint