Tag: angular

angular度上传的文件

我正在使用Angular,TypeScript发送一个文件,以及JSON数据到服务器。 以下是我的代码: import {Component, View, NgFor, FORM_DIRECTIVES, FormBuilder, ControlGroup} from 'angular2/angular2'; import {Http, Response, Headers} from 'http/http'; @Component({ selector: 'file-upload' }) @View({ directives: [FORM_DIRECTIVES], template: ` <h3>File Upload</h3> <div> Select file: <input type="file" (change)="changeListener($event)"> </div> ` }) export class FileUploadCmp { public file: File; public url: string; headers: Headers; constructor(public http: Http) { console.log('file upload […]

如何使用nginx proxy_pass保存请求的URL

我正在尝试使用瘦应用程序服务器,并有一个问题。 当nginx使用proxy_pass http://my_app_upstream;将请求代理到精简(或独angular兽)时proxy_pass http://my_app_upstream; 应用程序接收由nginx发送的修改的URL( http://my_app_upstream )。 我想要的是通过原来的URL和原来的请求从客户端没有任何修改,因为应用程序严重依赖于它。 nginx的文档说: 如果有必要以未处理的forms传输URI,则应使用伪指令proxy_pass,而不使用URI部分。 但我不明白如何configuration,因为相关的示例实际上是使用URI: location /some/path/ { proxy_pass http://127.0.0.1; } 那么你能帮我搞清楚如何保留客户端的原始请求URL吗?

Angular2 CLI错误“@ angular / compiler-cli”包未正确安装

我正在开发一个Angular 2项目。 现在尝试使用以下命令在当前项目中安装Angular CLI npm install –save-dev @angular/cli@latest npm install 问题是运行ng serve收到错误 The "@angular/compiler-cli" package was not properly installed. Error: The "@angular/compiler-cli" package was not properly installed. at Object.<anonymous> (/myng2project/node_modules/@ngtools/webpack/src/index.js:14:11) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (/myng2project/node_modules/@angular/cli/tasks/eject.js:10:19) at […]

Angular 2.0的风格绑定值

我试图从我的类(通过属性绑定获取)绑定一个颜色属性来设置我的div的背景颜色。 import {Component, Template} from 'angular2/angular2'; @Component({ selector: 'circle', bind:{ "color":"color" } }) @Template({ url: System.baseURL + "/components/circle/template.html", }) export class Circle { constructor(){ } changeBackground():string{ return "background-color:" + this.color + ";"; } } 我的模板: <style> .circle{ width:50px; height: 50px; background-color: lightgreen; border-radius: 25px; } </style> <div class="circle" [style]="changeBackground()"> <content></content> </div> 这个组件的用法: <circle color="teal"></circle> 我的绑定不起作用,但不会抛出任何例外。 […]

如何在CSS中使用3位数的颜色代码而不是6位数的颜色代码?

我最近浏览了我的CSS文件,并将所有6位hex代码切换为简单的3位代码(例如,我的#FDFEFF缩短为#FFF )。 它呈现出与以前几乎完全相同的颜色,在我看来,在两个部分之间是相当无用的,删除它们在我的CSS文件中保存了整个300字节。 使用哪个版本有关系吗? 我很less遇到只使用3位数字代码的网站(或者我想我从来没有碰到过这样的代码)。 使用3位密码,还是6位密码,还是我们应该使用完整的6位密码?

如何获得RxJS Subject或Observable的当前值?

我有一个Angular 2服务: import {Storage} from './storage'; import {Injectable} from 'angular2/core'; import {Subject} from 'rxjs/Subject'; @Injectable() export class SessionStorage extends Storage { private _isLoggedInSource = new Subject<boolean>(); isLoggedIn = this._isLoggedInSource.asObservable(); constructor() { super('session'); } setIsLoggedIn(value: boolean) { this.setItem('_isLoggedIn', value, () => { this._isLoggedInSource.next(value); }); } } 一切都很好。 但是我有另一个不需要订阅的组件,只需要在某个时间点获取isLoggedIn的当前值即可。 我怎样才能做到这一点?

我应该在Heroku Cedar上使用薄或独angular兽

我最近把我的应用程序升级到了heroku的雪松平台。 默认情况下,我使用thin作为Web服务器。 但是我一直很想用unicorn来实现并发性,并让我的美元换成父亲。 但是我担心在使用Thin之外的一些问题。 有没有人有这个决定真实的生活经验? 谢谢! 乔纳森 笔记: 这篇文章让我对这个想法感到兴奋: http : //michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-雪松堆栈/ 我知道每个应用程序是不同的,你应该build立一个登台环境,并为自己尝试。 但是,如果在你的升级环境下它看起来很棒,那么我们应该知道哪些陷阱? 我想知道为什么大家不应该这样做的原因

Pipe – Angular 2的参数是什么?

我已经使用下面的数字pipe道将数字限制在两位小数。 {{ exampleNumber | number : '1.2-2' }} 我想知道“1.2-2”背后的逻辑是什么? 我已经玩弄了这些试图实现一个filter到小数点后零的pipe道,但无济于事。

Angular2禁用button

我知道在angular2中我可以禁用一个带有[disable]属性的button,例如: <button [disabled]="!isValid" (click)="onConfirm()">Confirm</button> 但我可以用[ngClass]或[ngStyle]吗? 像这样: <button [ngStyle]="{disabled : !isValid}" (click)="onConfirm()">Confirm</button> 谢谢。

WPF矩形 – 只是顶angular

我怎么才能有一个WPF rectange四舍五入的顶angular? 我创build了一个边框,并设置了CornerRadius属性,并在边框内添加了我的矩形,但不起作用,矩形未被四舍五入。 <Border BorderThickness="1" Grid.Row="0" Grid.ColumnSpan="2" CornerRadius="50,50,0,0" BorderBrush="Black"> <Rectangle Fill="#FF5A9AE0" Grid.Row="0" Grid.ColumnSpan="2" Stretch="UniformToFill" ClipToBounds="True"/> </Border>