[英]gulp js gave the error when i changed my js files..| throw er
i build a new js file in my ng directory the user.svc.js , the contents of the file are 我在ng目录user.svc.js中构建了一个新的js文件,该文件的内容是
angular.module('app')
.service('UserSvc',function($http) {
var svc = this;
svc.getUser = function () {
return $http.get('http://localhost:3000/api/users',{
headers:{'X-Auth : this.token'}
})
}
svc.login = function(username,password){
return $http.post('http://localhost:3000/api/sessions',{
username:username,password:password
}).then(function(val){
svc.token = val.data;
return svc.getUser();
})
}
})
the error that I am getting is: 我得到的错误是:
C:\\Users\\setCodesToFire\\Documents\\modernweb\\app>gulp js
C:\\ Users \\ setCodesToFire \\ Documents \\ modernweb \\ app> gulp js
[00:57:06] Using gulpfile ~\\Documents\\modernweb\\app\\gulpfile.js[00:57:06]使用gulpfile〜\\ Documents \\ modernweb \\ app \\ gulpfile.js
[00:57:06] Starting 'js'...[00:57:06]正在启动“ js” ...
[00:57:06] Finished 'js' after 79 ms[00:57:06]在79毫秒后完成了“ js”
events.js:160
events.js:160
throw er;投掷者 // Unhandled 'error' event
//未处理的“错误”事件
^^
Error: app.js: error: couldn't process source due to parse error错误:app.js:错误:由于解析错误而无法处理源
Unexpected token (54:2)意外令牌(54:2)
can anyone tell me what is the problem.do it has to do something with the $http? 谁能告诉我问题出在哪里,它必须与$ http做些什么吗?
change the header values to object format instead of a string value 将标题值更改为对象格式,而不是字符串值
change this 改变这个
headers:{'X-Auth : this.token'}
to this 对此
headers: {
'X-Auth' : 'this.token'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.