我正在为一个项目使用Hapi.js,当我调用我的路由时,我要传递给处理程序的一个配置变量是未定义的。我做错了什么?
server.js
var Hapi = require('hapi');
var server = new Hapi.Server('0.0.0.0', 8080);
// passing this all the way to the handler
var config = {'number': 1};
var routes = require('./routes')(config);
server.rou
我已经创建了代码,它将覆盖类的默认配置,但我收到了奇怪的错误Type 'IConfig' is not assignable to type 'import("/Volumes/D/www/js/tsc_1/test").IConfig'.ts(2322) 我不能将相同的变量类型赋给另一个变量。请查看截图 export default interface IPlugin {
setConfig<T>(config: T): T
}
export interface IConfig {
port: number
}
con
我想知道如何调用这行代码中的waitForPin:
setTimeout(this.waitForPin, 100);
文件:
// namespace our code
window.App = {};
// my class (no Class.create in JQuery so code in native JS)
App.Something = function() {
};
// add functions to the prototype
App.Something.prototype = {
// automatically called
initial
我有这段代码,它抛出了下面的错误:
this.modifyAspect('health');
^
TypeError: Object #<Timer> has no method 'modifyAspect'
at Timer.tick (/Users/martinluz/Documents/Nodes/societ/node_modules/societal/societal.js:93:9)
at Timer.exports.setInterval.timer.ontime
function SomeService(Restangular) {
var promiseConf = getConf();
function getConf() { // get from database
return Restangular.all('conf').getList().then(function(conf) {
return conf;
})
}
function getConfObject() {
return promiseConf.then(confArr => {
re
我有一个父类A和另外两个扩展A的类B和C,我试图从一个子类(例如B)中更改父类A中的config属性,并自动与其他子类共享,例如C?
class A {
constructor() {
this.config = {};
}
}
class B extends A {
constructor() {
super();
}
updateConfig() {
this.config = "B";
}
}
class C extends A {
constructor() {
当我尝试从ConfigAppProviderModule导入测试时,我得到的错误是“没有导出的成员测试”。我在模块中使用config编写服务时犯了什么错误。
import { NgModule ,InjectionToken,Injectable } from '@angular/core';
export const ConfigToken = new InjectionToken<string>('ConfigToken');
class test {
config:any;
constructor(config){
this
这就是我想要做的:
从远程服务器脚本请求JSON对象
等待直到JavaScripts获得所有响应数据
从响应对象中打印值
我正在尝试在get配置函数中使用setTimeout,以便在1秒后回忆自己--如果值是未定义的,当它不再是未定义的时,使用该值执行一些操作。
或者,我似乎可以创建一个循环数秒的方法,但是如果有更好的方法来完成我想要做的事情,我想避免这样做?我的当前代码似乎没有任何延迟地恢复,这破坏了我的运行时。
谢谢您的建议,这是代码:
function runApplication() {
var initialiser = new Initialiser()
我想要的是修改类配置,然后在调用类之后,在我想要的任何文件中调用时,我希望修改后的值是常量。
class config{
constructor(config){
this.config = config;
}
}
class data extends config{
constructor(){
super()
console.log(this.config)
}
}
new config('123456789')
new data()
我为角js制作了一个代码库。我在库的主模块中创建了一个依赖于我的.config的moduleConfigProvider方法。我希望我的库的使用者在app.config阶段(在应用程序启动时)调用配置提供程序上的app.config。
问题是,我模块中的.config似乎运行在主应用程序模块的app.config之前。我该如何解决这个问题?
这就是我使用配置的方式。我需要在.config阶段使用它,因为我需要配置像$httpProvider这样的东西。
// this module provides initial configuration data for module
angular.m