这是我目前想要在我的组件中做的事情.每当我路由到不同的组件时,我想删除或销毁我的localStorage内容.我想实现这一目标,以避免localStorage变量存储以前的值,即使新值正在进入.我是否在正确的路径上?
游戏组件
export class Game implements OnDestroy{
constructor(){
this.currentGame = JSON.parse(localStorage.getItem('currentGame'));
}
ngOnDestroy(){
this.currentGame = null;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将CKEditor集成到我的角度项目中.我已经遵循了其他类似的解决方案,但只出现了textarea.这是我到目前为止所做的.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A Simple Page with CKEditor</title>
<!-- Make sure the path to CKEditor is correct. -->
<script src="../Email/ckeditor/ckeditor.js"></script>
</head>
<body>
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
import {Component} from '@angular/core';
@Component({
selector: 'test',
templateUrl:'test.html'
})
export class TestComponent {
}
Run Code Online (Sandbox Code Playgroud) 我有一个包含两个属性(Name_of_Game和Type_of_Game)的数据库表.我一直在将Name_of_Game提取到选择下拉列表中.但这就是我现在想要做的.从下拉列表中选择游戏后,如何将类型输入自动设置为游戏的相应类型?
例
游戏
指环王
类型
冒险
从下拉列表中选择响铃之后,类型输入框应自动设置为冒险.
//Component
export class ChatComponent{
Game : Games [];
constructor(private http:HttpService){
// list all games into the dropdown list
this.http.listgames()
.subscribe(data => {
this.Games = data;
})
}
//html
<div class="form-group">
<select class="form-control" name="game" [(ngModel)]="game.name" required>
<option *ngFor="let games of Games" [ngValue]="games" > {{games.name}} </option>
</select>
</div>
<div class="form-group">
<label for="type">Type:</label>
<input type="type" class="form-control" name="type" [(ngModel)]="game.type">
</div>
Run Code Online (Sandbox Code Playgroud) 是否可以使用ngModel?将数据绑定到标签?我想显示从数据库中获取的数据并使用标签显示而不是输入(文本框).
我一直在尝试实现Firebase文档中有关如何通过Firebase上的Facebook验证用户的逻辑.但我看起来更关注native android而不是Xamarin.任何人都可以用材料帮助我吗?我已经在网上和论坛上搜索了一些样本.