是否有可能从1而不是0开始ngFor index?
let data of datas;let i=index+1
Run Code Online (Sandbox Code Playgroud)
没用.
我正在尝试使用以下行:
import Clipboard = require('clipboard');
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
[default] c:\xampp\htdocs\isitperfect\node_modules\angular2-clipboard\src\clipboard.directive.ts:2:0
Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
Run Code Online (Sandbox Code Playgroud)
错误在这一行:
import Clipboard = require('clipboard');
Run Code Online (Sandbox Code Playgroud)
我试过了:
import * as Clipboard from 'clipboard';
Run Code Online (Sandbox Code Playgroud)
和其他一些变化,但无法弄清楚如何解决它.
我正在使用typescript 2.0.0
有任何想法吗?
我有以下textarea:
<textarea class="form-control" [(ngModel)]="content" name="content" required>
</textarea>
Run Code Online (Sandbox Code Playgroud)
和以下提交按钮:
<button type="submit" class="btn btn-default" [disabled]="content.valid">New comment</button>
Run Code Online (Sandbox Code Playgroud)
正如我在angular 2表格指南(https://angular.io/docs/ts/latest/guide/forms.html)中看到的,我可以使用x.valid它来检查它是否为空.
为什么我会收到TypeError: Cannot read property 'valid' of undefined错误?
目前,我有一个使用主app模块服务和路由的大型组件.我不确定为它创建一个新模块是否是一个好习惯.
我的问题:
我正在尝试使用角度材料2在我的网站上显示图标,但我有点困惑.
这是它应该如何工作,从材料2的github repo中的演示:
https://github.com/angular/material2/blob/master/src/demo-app/icon/icon-demo.ts
我一直在尝试使用它,但根本没有显示任何图标.
我就是这样设置的:
app.component.ts
import {MdIcon, MdIconRegistry} from '@angular2-material/icon/icon';
@Component({
...
encapsulation: ViewEncapsulation.None,
viewProviders: [MdIconRegistry],
directives: [MdIcon],
})
export class MyComponent{
constructor(private router: Router,
private JwtService:JwtService,
mdIconRegistry: MdIconRegistry){
mdIconRegistry.addSvgIconSetInNamespace('core', 'fonts/core-icon-set.svg')
}
}
Run Code Online (Sandbox Code Playgroud)
和模板..
<md-icon>home</md-icon>
Run Code Online (Sandbox Code Playgroud)
页面加载时没有错误,但没有显示图标.什么可能出错?
我有一个组件,这是我的主要界面.在此组件内部,单击按钮可打开离子2模态,允许选择项目.
我的模态页面(itemsPage):
..list of items here
<button ion-button [disabled]="!MY_TURN || !selectedItem || !selectedItem.quantity"
(click)="useItem(selectedItem)">
<span>Choose item {{selectedItem?.name}}</span>
</button>
Run Code Online (Sandbox Code Playgroud)
useItem() 应该:
我怎么能做这样的行动?找不到有关Ionic 2中模态和组件之间进行通信的任何文档.
我有以下代码:
//Loop: For each user ID/Role ID, get the data
userMeta.forEach((businessRole) => {
Observable.forkJoin(
af.database.object('/roles/'+businessRole.$value),
af.database.object('/users/'+businessRole.$key)
).subscribe(
data => {
console.log("Data received");
data[1].role = data[0];
this.users.push(data[1]);
},
err => console.error(err)
);
Run Code Online (Sandbox Code Playgroud)
我试图订阅使用2个observable的结果forkJoin.
由于某些原因,未显示"已接收数据"消息.
我的userMeta变量在console.log中看起来很好:
怎么了?
更新:以下代码也不返回任何内容
let source = Observable.forkJoin(
af.database.object('/roles/'+businessRole.$value),
af.database.object('/users/'+businessRole.$key)
);
let subscription = source.subscribe(
function (x) {
console.log("GOT: " + x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});
Run Code Online (Sandbox Code Playgroud)
我实际上要做的是提高以下代码的性能:
//Subscription 3: role ID to role Name
af.database.object('/roles/'+businessRole.$value) …Run Code Online (Sandbox Code Playgroud) 我正在学习Angular 2,我一直在使用静态数组,现在我正在尝试学习更多有关读取远程数据的知识.
我的app.component.ts:
import {Component} from 'angular2/core';
import {Http, Response} from 'angular2/http';
import {Observable} from 'rxjs/Rx';
@Component({
selector: 'my-app',
template:`
<h1>Angular2 HTTP Demo App</h1>
<h2>Foods</h2>
<ul>
<li *ngFor="#doc of docs">{{doc.id}}</li>
</ul>
`
})
export class AppComponent {
public foods;
public books;
public movies;
constructor(private http: Http) { }
ngOnInit() {
this.getFoods();
}
getFoods() {
this.http.get('http://my API URL')
.map((res:Response) => res.json())
.subscribe(
data => { this.foods = data},
err => console.error(err),
() => console.log('done')
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的API网址显示结果的方式:
我构建了一个应用程序,我打算与Angular 2和laravel进行实时战斗.例如,你点击"攻击"按钮,你的对手就会看到他的生命实时下降.
我的应用程序构建:
前端: Angular 2
后端: PHP Laravel 5.2
现在我正在搜索和学习我的实时战斗组件,我看到了不同的指南和教程:
第一个教程是关于如何使用Laravel 5和socket io.
在第二一个是如何利用角2 NODS JS和插座IO.
当我说实时时,我的意思是两个用户都看到屏幕上发生的同样事情)
我的后端和前端是完全分开的,我在我的应用程序的任何地方都没有设置NodeJS.
两个用户都需要在我的应用程序中看到战斗期间发生的操作,并且需要通过我的laravel API并通过我的Angular 2战斗组件显示
我的问题是 -
什么是使用Angular2和Laravel 5.2的实时应用程序(似乎websockets)的最佳方法,以获得我想要实现的目标的结果?
我的Laravel分页输出就像以前的laravel分页一样,但我需要为每个对象更改数据数组.我的输出是:
如您所见,数据对象有2个项目,我需要更改.
我的代码是:
$items = $this->items()
->where('position', '=', null)
->paginate(15);
Run Code Online (Sandbox Code Playgroud)
这返回带有数据透视表的用户项,但我不喜欢数据透视表在JSON中显示的方式,因此我决定更改项目并使用项目前的数据透视来组织每个项目.
为此,我试图使用 foreach
foreach ($items->data as $item)
{
}
Run Code Online (Sandbox Code Playgroud)
由于我不知道的原因,我给出了一个错误:
Undefined property: Illuminate\Pagination\LengthAwarePaginator::$data"
status_code: 500
Run Code Online (Sandbox Code Playgroud)
有帮助吗?
angular ×8
laravel ×2
angularfire2 ×1
clipboard ×1
ionic2 ×1
json ×1
node.js ×1
observable ×1
rxjs ×1
rxjs5 ×1
typescript ×1