我正在使用具有回调的javascript对象.我希望一旦触发回调来调用Angular2组件内的函数.
示例HTML文件.
var run = new Hello('callbackfunction');
function callbackfunction(){
// how to call the function **runThisFunctionFromOutside**
}
<script>
System.config({
transpiler: 'typescript',
typescriptOptions: { emitDecoratorMetadata: true },
packages: {'js/app': {defaultExtension: 'ts'}}
});
System.import('js/app/main')
.then(null, console.error.bind(console));
</script>
Run Code Online (Sandbox Code Playgroud)
我的App.component.ts
import {Component NgZone} from 'angular2/core';
import {GameButtonsComponent} from './buttons/game-buttons.component';
@Component({
selector: 'my-app',
template: ' blblb'
})
export class AppComponent {
constructor(private _ngZone: NgZone){}
ngOnInit(){
calledFromOutside() {
this._ngZone.run(() => {
this.runThisFunctionFromOutside();
});
}
}
runThisFunctionFromOutside(){
console.log("run");
}
Run Code Online (Sandbox Code Playgroud)
如何调用App.component.ts中的函数runThisFunctionFromOutside
在我在MySQL数据库和应用程序之间有缓存的架构中.我遇到了数据一致性的问题,因为我的缓存时间超过20分钟,因为它是一个非常高的负载服务器.
我的问题是如果我使用noSql数据库,是否还需要一个缓存服务器?这个想法是应用层和数据库层之间的内存缓存.
考虑替代我当前的架构.
在我的应用程序中,我想使用"斯坦福Javascript加密库",它有一个打字,我也看到https://github.com/Evgenus/sjcl-typescript-definitions.
我不明白我如何在我的项目中使用它.我如何sjcl.encrypt("password", "data")在我的项目中使用该命令
.
我使用角4,角度cli beta 2
我跑了 npm install --save-dev @types/sjcl
tsconfig.app.json
{
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": [ "sjcl" ]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"extends": "../tsconfig.json"
}
Run Code Online (Sandbox Code Playgroud)