草庐IT

服务工作

全部标签

javascript - 第一次加载组件时 Angular 4 ngOnInit 不工作

我在Angular4中有一个组件和一个用于更改路由的模板这个组件被调用但不加载任何没有服务器调用的东西。如果我将ngOnInit()方法内容放入构造函数中,它就可以正常工作。似乎没有调用ngOnInit。自从过去2天以来,任何人都可以帮助我处理这个问题。这是我的路由配置。consttestRouting:ModuleWithProviders=RouterModule.forChild([{path:'createtest/:id',component:TestComponent,resolve:{test:TestResolver}},{path:'createtest',compo

javascript - javascript 中的 .call 是如何工作的?

我在MDN站点上看到了这段代码:01functionProduct(name,value){02this.name=name;03if(value>=1000)04this.value=999;05else06this.value=value;07}0809functionProd_dept(name,value,dept){10this.dept=dept;11Product.call(this,name,value);12}1314Prod_dept.prototype=newProduct();1516//since5islessthan1000,valueisset17chee

javascript - 无法通过 phantomjs 网络服务器传送图像文件

我正在尝试让phantomjs网络服务器为我工作我想提供2个文件,html文件和一个png图像文件,html文件提供良好并在浏览器中正确呈现,但png文件不是这是服务器的代码varfs=require('fs');functionloadFile(name){if(fs.exists(name)){console.log(name+"Fileexist");returnfs.open(name,"r");}else{console.log("Filedonotexist");}}varserver,service;server=require('webserver').create()

javascript - 主干 collection.add 不工作

我有一个像这样的非常基本的设置:varMusicModel=Backbone.Model.extend({});varPlaylistCollection=Backbone.Collection.extend({model:MusicModel,events:{'add':'add'},add:function(mdl){//Thisisworkingperfectlyfineevenoutputofmodelconsole.log(mdl);}});varplaylistCollection=newPlaylistCollection();playlistCollection.add

javascript - 如何阻止 Node js服务器崩溃

我是nodejs的新手。我试图创建一个简单的HTTP服务器。我按照著名的例子创建了一个“HelloWorld!”服务器如下。varhandleRequest=function(req,res){res.writeHead(200);res1.end('Hello,World!\n');};require('http').createServer(handleRequest).listen(8080);console.log('Serverstartedonport8080');运行此代码将按预期正常启动服务器。但是尝试访问http://127.0.0.1:8080会抛出res1未定义的

javascript - node.js - 我无法重现来自服务器的渐进式响应

嗯,我是node.js的新手。开始尝试,我正在关注RyanDahl(http://www.youtube.com/watch?v=jo_B4LTHi3I)的介绍此时(大约0:17:00)有关于服务器如何处理响应的解释,基本示例是从网络服务器输出“hello”,然后在2秒后输出“world”,这段代码应该做到这一点//Requirethewebserverlibraryvarhttp=require('http');varserver=http.createServer(function(req,res){res.writeHead(200,{'content-type':'text-p

javascript - 成功登录后将用户数据从Nodejs服务器推送到Angular

我尝试使用PassportJS通过Facebook登录我的用户,并将用户数据传递给Angular。在服务器端,用户Controller中的Facebook回调代码看起来一切正常:exports.facebookCallback=function(){returnfunction(req,res,next){passport.authenticate('facebook',function(err,user,email){if(err||!user){returnres.redirect('/auth');}req.login(user,function(err){if(err){ret

javascript - Chrome 扩展程序与其余 Web 服务通信

我是chrome扩展的新手,我正在开发一个将与我的其余Web服务通信的扩展。我的其余Web服务将返回一个json字符串。我想做的是调用我的网络服务,获取响应json。目前我的background.js中有这个:chrome.browserAction.onClicked.addListener(function(tab){chrome.tabs.getSelected(null,function(tab){varlink=tab.url;alert(link);});});我的计划是当用户点击图标扩展时,当前选项卡url将被发送到我的网络服务,它会得到响应json。我的问题是,在C#中

javascript - D3.js - 选择如何工作 - 需要对 Mike 的文章进行澄清

在http://bost.ocks.org/mike/selection/,Mike谈到在选择上应用函数。Whenyouuseafunctiontodefineaselection.attrorselection.style,thefunctioniscalledforeachelement;themaindifferencewithgroupingisthatthesecondargumenttoyourfunction(i)isthewithin-groupindexratherthanthewithin-selectionindex.这可能很简单,但出于某种原因,我不能完全理解这

javascript - socket.io 在服务器离线时发出

我正在使用socket.iov1.3.6(nodejs)并尝试使用以下代码从浏览器发出数据。客户端代码varsocket=io.connect('http://something.com:3300/');functionsendMessage(message){ socket.emit('message',message);}服务器代码vario=require('socket.io').listen(3300);io.sockets.on('connection',function(socket){messageHandler(socket);});functionmessageHa