Javascript SyntaxError:应为表达式,Get'';呼噜声
首先,我是grunt和angularjs的新手,基本上这是我第一个真正的项目。我喜欢使用持续集成,因为我决定使用grunt来构造我的分发代码 我将grunt contrib copy()与以下Gruntfile.js文件配置一起使用:Javascript SyntaxError:应为表达式,Get'';呼噜声,javascript,angularjs,node.js,gruntjs,grunt-contrib-copy,Javascript,Angularjs,Node.js,Gruntjs,Grunt Contrib Copy,首先,我是grunt和angularjs的新手,基本上这是我第一个真正的项目。我喜欢使用持续集成,因为我决定使用grunt来构造我的分发代码 我将grunt contrib copy()与以下Gruntfile.js文件配置一起使用: module.exports = function(grunt) { // Load grunt tasks automatically require('load-grunt-tasks')(grunt); // Time how long tasks ta
module.exports = function(grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Define the configuration for all the tasks
grunt
.initConfig({
// Automatically inject Bower components into the app
bowerInstall : {
target : {
src : [ 'index.html' ],
exclude : [
'bower_components/angular/angular.min.js',
'bower_components/angular-route/angular-route.min.js',
'bower_components/angular-sanitize/angular-sanitize.min.js',
'bower_components/angular-translate/angular-translate.min.js',
'bower_components/bootstrap/dist/js/bootstrap.min.js',
'bower_components/bootstrap-social/js/bootstrap.min.js',
'bower_components/jquery/dist/jquery.min.js',
'bower_components/metisMenu/dist/metisMenu.min.js',
'bower_components/morrisjs/morris.min.js',
'bower_components/raphael/raphael-min.js' ]
}
},
// Copies remaining files to places other tasks can use
copy : {
html : {
src : 'index.html',
dest : 'dist/index.html'
},
angular : {
expand : true,
cwd : 'app',
dest : 'dist/app',
src : [ '**/*.js' ]
},
bower : {
expand : true,
cwd : 'bower_components',
dest : 'dist/bower_components',
src : [ '**/*.*' ]
},
assets : {
expand : true,
cwd : 'assets',
dest : 'dist/assets',
src : '**/*.{png,jpg,jpeg,gif,css}'
},
views : {
expand : true,
cwd : 'views',
dest : 'dist/views',
src : '**/*.html'
}
},
targethtml : {
dist : {
files : {
'dist/index.html' : 'dist/index.html'
}
}
},
compress : {
main : {
options : {
mode : 'tgz',
archive : 'target/geneBlab.tgz'
},
files : [ {
expand : true,
src : '**/*',
cwd : 'dist/',
dot : true
} ]
}
}
});
grunt.registerTask('default', [ 'copy' ]);
};
我的结构文件夹是:
-app
|--app.js
|--controllers
| |...
|--i18
| |...
|--js
|...
-bower_components
|...
-views
|...
-assets
|...
-index.html
在运行grunt命令之前,我已经将它正确地组织到dist文件夹中,但不幸的是,当我尝试打开index.html firebug时,它在所有javascript文件中显示以下错误:SyntaxError:expected expression,get'.'
我的一个javascript文件:
'use strict';
testControllers
.controller(
'testController',
[
'$scope',
'$http',
'$routeParams',
'dnaToolsService',
function($scope, $http, $routeParams, dnaToolsService) {
/***************************************************
* VARIABLES
**************************************************/
/**
* Control the input/output flow
*/
$scope.status = 'input';
$scope.dna = new Object();
$scope.openDetails = new Array();
/***************************************************
* INPUT/OUTPUT METHODS
**************************************************/
/**
* Calculate the dna sequence result
*/
$scope.calculateResult = function($dna) {
$scope.dna = callGetSpeciesUsingDna();
$scope.status = 'output';
// Start the array to hide and show details
for (var index = 0; index < $scope.dna.speciesList.length; index++) {
$scope.openDetails.push(false);
}
};
/**
* Show the data detail
*/
$scope.showDetails = function($index, $simpleDetail) {
$scope.openDetails[$index] = ($scope.openDetails[$index] == false) ? true
: false;
}
/**
* Back the page to input
*/
$scope.back = function() {
$scope.status = 'input';
};
/***************************************************
* INTERNAL/HELP METHODS
**************************************************/
function callGetSpeciesUsingDna() {
return dnaToolsService.getSpeciesUsingDna();
}
this.params = $routeParams;
} ]);
“严格使用”;
测试控制器
.控制员(
“testController”,
[
“$scope”,
“$http”,
“$routeParams”,
“dnaToolsService”,
函数($scope、$http、$routeParams、dnaToolsService){
/***************************************************
*变数
**************************************************/
/**
*控制输入/输出流
*/
$scope.status='input';
$scope.dna=新对象();
$scope.openDetails=新数组();
/***************************************************
*输入/输出方法
**************************************************/
/**
*计算dna序列结果
*/
$scope.calculateResult=函数($dna){
$scope.dna=callGetSpeciesUsingDna();
$scope.status='output';
//启动阵列以隐藏和显示详细信息
对于(变量索引=0;索引<$scope.dna.speciesList.length;索引++){
$scope.openDetails.push(false);
}
};
/**
*显示数据详细信息
*/
$scope.showDetails=函数($index,$simpleDetail){
$scope.openDetails[$index]=($scope.openDetails[$index]==false)?true
:假;
}
/**
*返回页面以进行输入
*/
$scope.back=函数(){
$scope.status='input';
};
/***************************************************
*内部/帮助方法
**************************************************/
函数调用GetSpeciesUsingDNA(){
返回dnaToolsService.getspecieusingdna();
}
this.params=$routeParams;
} ]);
为什么会这样
谢谢你抽出时间;) 您认为问题在于插件版本吗D 我正在使用grunt副本,该插件已被删除…我更改了grunt contrib副本的插件,并且所有开始工作正常:O 链接参考:
谢谢大家。它是否告诉您错误在哪一行?是的。例如:SyntaxError:应为表达式,得到“”。angular-route.js(linha 1017)顺便说一下…在我的控制器grunt中添加字符“.”