Tag: 量angular器

在angular度2中设置material-datepicker的date格式

我是'angular2'和'angular js material'中的新成员。 我在我的项目中使用material-datepicker。 这是我的dateselect器代码 <material-datepicker placeholder="Select Date" [(date)]="currentDate" name="currentDate" required></material-datepicker> 它将显示在浏览器中,如下所示。 我关心的是date格式问题。 如何设置2017/04/27至2017年4月27日的date格式。

angular度茉莉花testingHTML注入失败

我无法注入我的HTML模板到我的茉莉花testing。 我该如何解决这个错误? 错误:此testing模块使用使用“templateUrl”或“styleUrls”的组件FooDetailComponent,但它们从未编译过。 testing前请打“TestBed.compileComponents”。 我的testing显然调用compileComponents() ,并且还设置了templateUrl ,所以我不清楚如何进行。 foo-detail.component.ts定义: @Component({ selector: 'my-selector', templateUrl: './foo-detail.component.html' }) export class FooDetailComponent implements OnInit, OnDestroy { … } FOO-detail.component.spec.ts: describe('Component Tests', () => { describe('Foo Management Detail Component', () => { let comp: FooDetailComponent; let fixture: ComponentFixture<FooDetailComponent>; let service: FooService; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [FooDetailComponent], providers: [ MockBackend, BaseRequestOptions, […]

如何发送消息与websocket

我试图在WebSocket中发送消息到TypeScript。 我用两个函数创build了一个Socket服务:.onMessage()和.emit(message): import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { Message } from '../message/message.model'; import * as socketIo from 'socket.io-client'; const SERVER_URL = 'http://localhost:8080'; @Injectable() export class SocketService { private socket; public initSocket(): void { this.socket = socketIo(SERVER_URL); } public send(message?: Message): void { this.socket.emit('displayHello', { to: 'flo@NXS_DEV_FLO2', from: […]

在量angular器testing中使用$ rootScope

我试图做一个End2Endtesting,我需要从服务器(嘲笑它)操纵数据…有没有一种方法来访问在量angular器$ rootScope,以便我可以告诉服务器(节点)什么数据,我正在寻找完成testing? 我会把rootScope作为一个“之前”的量angular器注入,然后当我需要操作数据时,我可以。 请告知如何做到这一点,或者如果有另一种方式来做到这一点。

量angular器不会暂停debugging

我试图debuggingProtractor-E2E-Tests但我的testing不会暂停browser.debugger() 。 我试图做到这一点是 运行'webdriver-manager start'启动我的selenium服务器 将browser.debugger()插入到我的testing代码中 运行grunt serve启动我的应用程序 运行protractor debug protractor.conf.js 我的步骤3的控制台输出如下: Starting background Express server debugger listening on port 5858 Express server listening on 9000, in development mode 我的控制台输出第4步是以下内容: $ protractor debug protractor.conf.js Starting debugger agent. debugger listening on port 5858 Starting selenium standalone server… connecting… ok debug> Selenium standalone server started at http://192.168.1.101:57265/wd/hub […]

期待在茉莉花不完全工作

我正在用量angular器进行jasinetesting,我不确定期望如何工作。 我期望茉莉花给我一个失败,因为我显然有一个失败的期望。 它并没有。 我使用使用Jasmine2的grunt-protractor-runner 1.2.1。 我有这个testing用例: var validateObject = function(object) { expect('1.0').toEqual('1.0'); //no error //expect('1.1').toEqual('1.0'); //error console.log(object['property']); //1.0 console.log(object['property'] === '1.0'); //true console.log(typeof object['property']); //string /*PROBLEM STARTS HERE*/ expect(object['property']).toEqual('1.0'); //no error expect(object['property']).toEqual('1.1'); //no error }; var readSomething = function(done) { fs.createReadStream('folder + fileName') .pipe(operation.Parse()) .on('entry', function(file) { validateObject(file); .on('end', function(){ done(); }); }; describe('test this', […]

试图在angular2中使用stomp.js

我正在试图使用stomp.js实现一个Stomp Websocket客户端。 我正在使用typescript和webpack的angular2,并且对于所有这些技术都是新的。 我的angular2项目是build立在这个种子: https : //github.com/angular/angular2-seed 作为实现stomp.js客户端的指南,我使用了https://github.com/sjmf/ng2-stompjs-demo 我目前收到的错误如下: ?d41d:73 EXCEPTION: TypeError: Cannot read property 'client' of undefined in [null] 错误发生在这个方法中: public configure() : void { // Check for errors if (this.state.getValue() != STOMPState.CLOSED) { throw Error("Already running!"); } let scheme : string = 'ws'; if( AppSettings.IS_SSL ) { scheme = 'wss'; } this.client = […]

无法加载app.html

当我在@Component使用templateUrl ,我在浏览器控制台中得到以下错误。 @Component({ selector: 'http-app', directives: [ ], templateUrl: "app.html", }) class HttpApp { } 错误:未被捕获(承诺):无法加载app.html resolvePromise @ http:// localhost:8080 / vendor.js:6504:33 makeResolver / <@ http:// localhost:8080 / vendor.js:6481:15 ApplicationRef_http:// localhost:8080 / common.js:9943: 266 /http://localhost:8080/vendor.js:6289:21 NgZoneImpl / this.inner <.onInvoke @ http:// localhost:8080 / common.js:10351:33 / http: //localhost:8080/vendor.js:6288:21 [616] /http://localhost:8080/vendor.js:6182:26 scheduleResolveOrReject / <@ http:// localhost:8080 / […]

什么阻止我的AngularJs 2应用程序运行检查器中显示的命令?

我正在尝试使用Angular 2.我使用npm start在Chrome中创build一个实时编码环境,并且看到不寻常的行为。 我的代码库的早期版本在文件A.service.ts中出现如下: export class AService{ constructor( private http : Http ){} test( valueA : string, valueB : string ){ var dataObj = { valueA, valueB } console.log( dataObj ); console.log( this.http ); } } 运行我的程序后,控制台将成功显示两个对象。 第一个对象向我展示了值“valueA”和“valueB”,第二个对象是一个Http对象,向我展示了我的服务已经正确加载了,并且方法正在被期望的值所调用。 为了将来的参考,我们将调用这个控制台日志模式“输出A”。 我改变了我的服务定义。 我改了几次。 每次保存文件的新版本时,应用程序都会自动重新加载。 在每个版本上,我都试图将代码和控制台输出添加到服务对象testing方法中。 但是,在每次迭代中,只会出现“输出A”。 我删除了testing方法的所有原始代码,然后再次运行代码,仍然看到“输出A”。 我遵循检查器中的代码执行,检查员将我逐行放在新代码上,现在看起来像这样: export class AService{ constructor( private http : Http ){} […]

从angular色2应用程序的Firebase云端函数发送mailgun电子邮件

我正尝试使用Firebase云端函数的Mailgun API来发送电子邮件。 我已经尝试在Cloud Function中实现相同的nodejs教程,但是我总是得到“错误:无法处理请求”。 请问我做错了什么。 云端函数代码如下: <pre> <code> var functions = require('firebase-functions'); var nodemailer = require('nodemailer'); var auth = { auth: { api_key: '###################', domain: 's###############g' } } exports.helloWorld = functions.https.onRequest((request, response) => { response.send("Hello from Firebase!"); }); var nodemailerMailgun = nodemailer.createTransport(auth); exports.sendEmail = functions.https.onRequest((request, response) =>{ //app.get('/', function(req, res) { test(); }); function test(){ […]