Tag: angular

Angular 2从inputtypes=file upload文件

使用angular2testing版,我似乎无法获得input的types文件的工作。 使用诊断,我可以看到其他type如文本的双向绑定。 <form> {{diagnostic}} <div class="form-group"> <label for="fileupload">Upload</label> <input type="file" class="form-control" [(ngModel)]="model.fileupload"> </div> </form> 在我的打字稿文件中,我有可用的诊断行: get diagnostic() { return JSON.stringify(this.model); } 难道是不是JSON的问题? 该值为null 。 我无法真正validationinput的价值; 不知何故,即使“select文件…”旁边的文本更新,我不能看到DOM的差异。

如何处理angular2中的查询参数

在我的routable component中 @RouteConfig { {path: '/login', name: 'Login', component: LoginComponent} } 但是,如果我去app_url/login?token=1234我怎么得到查询参数?

调用子组件的方法

我有一个嵌套的子组件像这样: <app-main> <child-component /> </app-main> 我的appMain组件需要在子组件上调用一个方法。 如何在子组件上调用一个方法?

angularjs:防止Bootstrap莫代尔消失,当点击外面或按逃生?

我使用angular引导来呈现一个模态。 但是我的要求是防止在模式外单击或按下退出键时popup解除。 我遵循angular度bootstrap网站上的教程: http : //angular-ui.github.io/bootstrap/

文件“app / hero.ts”不是在控制台中的模块错误,在哪里存储接口文件在目录结构与angular2?

我正在做这个地址的angular2教程: https : angular2我已经把hero界面放在app文件夹下的单个文件,在控制台我有这个错误: app/app.component.ts(2,20): error TS2306: File 'app/hero.ts' is not a module. [0] app/hero-detail.component.ts(2,20): error TS2306: File 'app/hero.ts' is not a module. 如果我把我的接口文件放在一个英雄文件夹的错误消失, 这是没有在文档中提到,我的导入有什么问题 ? 在app.components.ts和hero-detail.component.ts我的导入指令(以组件文件hero-detail.component.ts : import {Component} from 'angular2/core'; import {Hero} from './hero'; 我必须用 import {Hero} from './'; replace我的导入指令: import {Hero} from './'; 或者只是把代码放在一个英雄文件夹 ? 谢谢你的回答。

angular度2改变每个按键的事件

只有在input焦点发生变化后才会调用change事件。 我怎样才能让事件触发每个按键? <input type="text" [(ngModel)]="mymodel" (change)="valuechange($event)" /> {{mymodel}} 第二个绑定改变每个按键btw。

如何在angular-cli项目中升级Angular 2版本?

我正在尝试将我的angular 2项目从2.0.0升级到2.4.1。 我明白从2.0.0版本开始就采用了语义版本pipe理,而2.xx版本应该是直接replace。 我的经验似乎另有说明。 也许我只是不知道我在做什么,但我还没有发现这是简单的… 尝试1 – 手动版本升级 我天真的第一种方法是手动更新我的@angular色依赖关系。 你可以在下面引用我的package.json(更新1)。 我做了这些改变,然后做了一个npm install ,我得到了几个警告,然后当我尝试执行ng serve时出现以下错误。 无法读取未定义的属性“AssetUrl” 我的警告 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN @angular/core@2.4.1 requires a peer of rxjs@^5.0.1 but none was installed. npm WARN @angular/core@2.4.1 requires a […]

Angular2相当于$ document.ready()

简单的问题,我希望。 我希望在$ document.ready()的Angular2等价物被激发时运行一个脚本。 达到这个目标的最好方法是什么? 我已经尝试把脚本放在index.html的末尾,但是我发现这不起作用! 我认为它必须进行某种组件声明? 是否有可能从.js文件运行加载脚本? 编辑 – 代码: 我有以下js和css插件注入我的应用程序(从铸造HTML主题 )。 <link href="css/themify-icons.css" rel="stylesheet" type="text/css" media="all" /> <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" /> … <script src="js/jquery.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/flexslider.min.js"></script> … <script src="js/scripts.js"></script> //This initiates all the plugins 如上所述,scripts.js“实例化”整个事情,因此需要在Angular准备好之后运行。 的script.js 得到它的工作: import {Component, AfterViewInit} from 'angular2/core'; @Component({ selector: 'home', templateUrl: './components/home/home.html' }) export class […]

Angular 2引导函数给出错误“参数typesAppComponent不能分配给参数typesType”

这是我的第一个简单的Hello Worldangular2应用程序从Angular 2快速入门指南 。 import {Component} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; @Component({ selector: 'ng2-app', template: '<h1>My first Angular 2 App</h1>' }) export class AppComponent { } bootstrap(AppComponent); 应用程序运行正常,当我用npm start运行,但我的IntelliJ IDE显示错误与bootstrap(AppComponent) 参数typesAppComponent不能分配给参数typesType 查看bootstrap函数声明, AppComponent需要扩展Type 。 export declare function bootstrap(appComponentType: Type, customProviders?: Array<any>): Promise<ComponentRef>; 我的问题是: 是否期望Angular组件能够扩展Type ?

无法绑定到“formControl”,因为它不是“input”的已知属性 – angular2材料自动完成问题

我正在尝试在我的angular2项目中使用angular度材料自动完成组件。 我添加了以下到我的模板。 <md-input-container> <input mdInput placeholder="Category" [mdAutocomplete]="auto" [formControl]="stateCtrl"> </md-input-container> <md-autocomplete #auto="mdAutocomplete"> <md-option *ngFor="let state of filteredStates | async" [value]="state"> {{ state }} </md-option> </md-autocomplete> 以下是我的组件。 import {Component, OnInit} from "@angular/core"; import {ActivatedRoute, Router} from "@angular/router"; import {FormControl} from "@angular/forms"; @Component({ templateUrl: './edit_item.component.html', styleUrls: ['./edit_item.component.scss'] }) export class EditItemComponent implements OnInit { stateCtrl: FormControl; states = […]