我想将我的枚举显示为字符串,但将其显示为数字。
我正在从Web服务接收json对象,并将其映射到我的Typescript对象
getProperties(): Observable<Property[]> {
return this.http.get<Property[]>(this.getallagentsproperties + '1');
}
export enum LetType {
Notspecified = 0,
LongTerm = 1,
ShortTerm = 2,
Commercial = 4
}
export class Property {
...other stuff...
letType: LetType;
...other stuff...
}
Run Code Online (Sandbox Code Playgroud)
我的组件会进行调用并将其添加到相关属性中
import { Component, OnInit } from '@angular/core';
import { Property } from './Property';
import { PropertyService } from '../properties.service';
@Component({
selector: 'app-properties',
templateUrl: './properties.component.html',
})
export class PropertiesComponent implements OnInit {
properties: Property[];
constructor(private propertyService: PropertyService) { }
ngOnInit() {
this.getProperties() …Run Code Online (Sandbox Code Playgroud) 几个月前,我为朋友整理了一个使用Wordpress的网站,我在localhost上开发了它并将其导出到他的实时网站paulscreen.com
我最近被要求为其他人做同样的事情,我也以同样的方式设置它,我的问题是在某些时候我访问了paulscreen.com(我不知道如何或何时)并且这样做我已经设置了他的站点到viciousnature.co.uk,我假设通过更改管理区域的选项面板中的主页.
现在,当我尝试访问第一个站点的管理区域时,我被重定向到第二个站点.我一直在阅读wordpress代码,但只有有限的编码知识,无法找到如何解决这个问题.
如何在不使用管理区域的情况下找到编辑主页面的选项?
我正在创建一个模块(我的第一个模块,没有教程)并且收到了错误
'无法检索实体配置'
在环顾各种网站并尝试不同的选择后,我停下来了.我假设完整的消息:
Error in file: "/Users/myname/Sites/magentotest/app/code/local/Ps/Pref/sql/pref_setup/mysql4-install-0.1.0.php" - Can't retrieve entity config: pref/prefNewsSignUp
Run Code Online (Sandbox Code Playgroud)
问题出在我的config.xml上,我需要在某个地方添加一个实体节点,其中包含与mysql4有关的内容.....但我需要添加的内容以及我需要放在该节点中的内容仍然是一个谜我此刻 我的配置文件是
<global>
<model>
<pref>
<class>Ps_Pref_Models</class>
</pref>
</model>
<resources>
<pref_setup>
<setup>
<module>Ps_Pref</module>
<class>Ps_Pref_Models_Resource_Setup</class>
</setup>
</pref_setup>
</resources>
</global>
Run Code Online (Sandbox Code Playgroud)
============================== 编辑 =================== =============
我现在回到教程阶段,试着去理解我哪里出错了.这个Alan Storm教程 看起来非常类似于我的目标,但我仍然遇到了"无法检索实体配置"的相同问题(我已经完成了所有我的配置和var_dumped在IndexController中的各种选项,但是无法获得传递了这个问题,这对我没有任何意义)我留下了一些我认为有用的var_dump以及它们返回的内容(我希望这个编辑不会太混乱)
文件结构
+诗
- + Prefcentre
- +型号
--- + Mysql4
---- Preferences.php
--- Preferences.php
- +控制器
--- IndexController.php
- +等
--- config.xml中
PS/Prefcentre /型号/ Mysql4 /首选项
class Ps_Prefcentre_Model_Mysql4_Preferences
extends Mage_Core_Model_Mysql4_Abstract
{
protected function _construct()
{
$this->_init('prefcentre/preferences', 'prefcentre_id');
}
}
Run Code Online (Sandbox Code Playgroud)
PS/Prefcentre /型号/首选项
class …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用magento的命令加入两个自定义表.搜索后,我遇到了这个通用代码块
$collection = Mage::getModel('module/model_name')->getCollection();
$collection->getSelect()->join( array('table_alias'=>$this->getTable('module/table_name')),
'main_table.foreign_id = table_alias.primary_key',
array('table_alias.*'),
'schema_name_if_different');
Run Code Online (Sandbox Code Playgroud)
在此之后为模板我试图加入我的表连接在一起,但只返回错误,如incorrect table name或table doesn't exist或其他一些错误.
只是为了清理事情,有人可以根据我的理解纠正我
$collection = Mage::getModel('module/model_name')->getCollection();
获取模型的实例.在该模型中是保存所需数据的表(对于此示例,我将调用表p)
$collection->getSelect()
从表p中选择数据
->join()
需要三个参数才能将两个表连接在一起
PARAM1
array('table_alias'=>$this->getTable('module/table_name'))
'您为表提供的名称'=>'要添加到集合中的表(已在模型文件夹中设置)'
PARAM2
'main_table.foreign_id = table_alias.primary_key'
这一点我没有得到(虽然看起来很直接)
我的主表(p)没有外来ID(它有它的主键 - 它也是它的外来ID)?
必须等于你在param1中给出的字母名称
参数3
'main_table.foreign_id = table_alias.primary_key'
从所有名称中获取所有内容
我的理解在哪里出错了?
我正在尝试PHPUnit_Selenium使用命令安装
pear install phpunit/PHPUnit_Selenium
我正在运行的梨版本是 1.9.4。上面的命令返回
正在尝试发现频道“phpunit”...尝试在频道“phpunit”上回退到 https 而不是 http...“phpunit/PHPUnit_Selenium”中的未知频道“phpunit”无效包名称/包文件“phpunit/PHPUnit_Selenium”安装失败
搜索谷歌我发现这个(几次)作为建议。所以我试过了
pear channel-discover pear.phpunit.de
和
sudo pear channel-discover pear.phpunit.de (以防它有所作为)
上一个命令返回
通过 http:// 发现频道 pear.phpunit.de 失败并显示消息:频道添加:无法打开“ http://pear.phpunit.de/channel.xml ”(文件http://pear.phpunit.de:80 /channel.xml无效(收到:HTTP/1.1 403 Forbidden(Forefront TMG 拒绝指定的统一资源定位符(URL)。)))试图通过 https:// 发现频道 pear.phpunit.de 而不是发现频道“pear” .phpunit.de”失败(频道添加:无法打开“ https://pear.phpunit.de/channel.xml ”(连接到`pear.phpunit.de:443'失败:操作超时))
我需要做什么来安装 PHPUnit_Selenium?
我正在尝试向我的淘汰赛 js 模型添加一个脏标志(我希望这是一个简单的任务),当任何属性发生更改时,该标志将更新。
我在发帖之前完成了一些研究,发现大多数答案都指向这篇博客文章,还有一个链接到该文章的小提琴,我试图遵循它,但没有成功。
我还尝试使用 jquery 来监听输入或选择元素何时发生更改,但是当填充输入时会触发页面加载,因此该标志始终会被设置为脏。
我的模型和示例之间的区别是我使用自动映射器
在示例中它显示Item有一个dirty标志。使用自动映射器时我将如何复制它?(我添加了我的 json 模型,以防它有助于提供“最佳”解决方案)
示例中的 JS
ko.dirtyFlag = function(root, isInitiallyDirty) {
var result = function() {},
_initialState = ko.observable(ko.toJSON(root)),
_isInitiallyDirty = ko.observable(isInitiallyDirty);
result.isDirty = ko.computed(function() {
return _isInitiallyDirty() || _initialState() !== ko.toJSON(root);
});
result.reset = function() {
_initialState(ko.toJSON(root));
_isInitiallyDirty(false);
};
return result;
};
function Item(id, name) {
this.id = ko.observable(id);
this.name = ko.observable(name);
this.dirtyFlag = new ko.dirtyFlag(this);
}
var ViewModel = function(items) {
this.items = ko.observableArray([
new …Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试使用 angular 9 中的 rxjs,并且我正在尝试根据 observable 的响应有条件地进行调用,但如果没有嵌套订阅,似乎无法让它工作。我已经阅读了几篇文章,包括这个和这个,但我似乎无法解决我的问题。
在我的阅读中,我还阅读了这篇 SO post
单击确认按钮时触发 中的confirmed()方法DialogConfirmService
请注意,我尝试了两次以上的重构,但发布的重构是我一直在尝试的示例。
我当前的工作解决方案(我想摆脱嵌套订阅)
this.dialogConfirmService
.confirmed()
.pipe(take(1))
.pipe(map(x => {
this.isSaving = true;
return x;
})
)
.subscribe(confirmed => {
if (confirmed) {
this.myService.save('', '')
.pipe(take(1))
.subscribe(
(data) => this.onSuccess(data),
(error) => this.handleError(error)
);
}
});
Run Code Online (Sandbox Code Playgroud)
我的重构失败 1
this.dialogConfirmService
.confirmed()
.pipe(take(1))
.pipe(
map(x => {
this.isSaving = true;
console.log(x);
return x;
}
),
mergeMap(cv =>
this.myService.save(
this.rulesetForm.controls.name.value,
JSON.parse(this.rulesetForm.controls.definiation.value)
)
)).subscribe(j => …Run Code Online (Sandbox Code Playgroud)