在搜索时我发现了一些名为moduleId设置模板和CSS文件的相对路径的东西,但我moduleId不确切知道如何在我们的angular2组件中使用?
实际上,问题出在我的文件夹结构中.我从dist文件夹加载我的所有.js文件,而我的视图(.html文件)在src文件夹中.所以当我使用moduleId: module.id像这样的角度从dist文件夹,而不是src文件夹采取路径.
所以这里有人帮我告诉我如何为我的组件angualr2设置自定义moduleId?
我的文件夹结构是这样的.
App
/\
/ \
(.js + .map files)Dist Src(.ts + .html + .css files)
Run Code Online (Sandbox Code Playgroud)
实际编码(工作) -
@Component({
selector: 'class-timing',
templateUrl: 'src/components/TimeTable/class-timing/class-timing.html',
styleUrls: ['src/app.css']
})
Run Code Online (Sandbox Code Playgroud)
修改编码(由于路径不正确而无法工作) -
@Component({
selector: 'class-timing',
templateUrl: 'class-timing.html',
moduleId: module.id,
styleUrls: ['src/app.css']
})
Run Code Online (Sandbox Code Playgroud)
参考本教程 http://schwarty.com/2015/12/22/angular2-relative-paths-for-templateurl-and-styleurls/
有没有办法将类应用于Angular中的每个路由组件.一种方法是使用host每个组件的属性
@Component({
moduleId: module.id,
selector: 'one',
host :{class :'my-class'}
templateUrl: 'one.html',
})
Run Code Online (Sandbox Code Playgroud)
但我不想为每个组件写这个.
我在我的应用程序中使用Picker组件.并且屏幕上有列表视图.根据选择器的选定值,列表视图会更新.这是代码
<Picker style={{ flex: 0.3, marginTop: -10 }}
selectedValue={this.state.helpModel.needyType}
onValueChange={(itemValue, itemIndex) => {
this.setState((prevState) => {
return { helpModel: { needyType: itemValue, helpStatus: prevState.helpModel.helpStatus } }
});
this.getNeedies(this.state.helpModel);
}}>
{this.state.helpCategory.map((data, index) => {
return (
<Picker.Item key={data.id} label={data.title} value={data.value} />
);
})}
</Picker>
Run Code Online (Sandbox Code Playgroud)
我使用状态变量(this.state.helpModel.needyType)来绑定selectedValue选择器和onValueChange我正在更新状态变量.然后基于this.state.helpModel将获取列表数据并更新列表视图的方法调用该方法.但是helpModel没有立即获得更新,因此它保留了先前的值一段时间,但是在那个时间getNeedies方法被调用并且基于先前的值数据被请求.
可能是因为setState是异步行为.使用getNeedies后用2-3秒钟调用方法解决了这个问题setTimeout.但有没有更好或更优雅的方式来做同样的事情?可能会.then像promises?
我刚开始使用React Native,所以如果这个问题太基础,请忽略.
我想对齐文本内容和头像圈。这是我定义的类
.user-detail {
display: inline-block;
text-transform: uppercase;
text-align: right;
.user-detail__username {
margin: 18px 16px 0px 10px;
display: block;
float: left;
font-size: $font-size;
font-weight: 500;
}
.user-detail__role {
margin: 18px 16px 0px 10px;
display: block;
font-size: $font-size * 0.9;
font-style: normal;
line-height: 13px;
font-weight: 300;
}
.user-detail__avatar-circle {
display: inline-block;
margin: 8px 11px 0px 0px;
width: 45px;
height: 45px;
border-radius: 50%;
border: 1px solid $lightstroke;
}
.user-detail__avatar {
position: relative;
font-size: 51px;
line-height: 43px;
left:-4px;
}
}
Run Code Online (Sandbox Code Playgroud)
这是 HTML 标记
<div …Run Code Online (Sandbox Code Playgroud) 我在表中有一个 jsonb 字段。我想更新一个单独的键值,所以我使用 jsonb_set 方法。我要更新的密钥在一个变量中。
这是我要更新的 jsonb 对象
{"yes":5,"total_votes":6,"no":1}
Run Code Online (Sandbox Code Playgroud)
关键变量vote_to是yes.
这是我正在尝试的方式
update polls set result = jsonb_set(result, ('{'||vote_to||'}'),vote_count::text::jsonb) where id=_poll_id;
Run Code Online (Sandbox Code Playgroud)
错误是
ERROR: function jsonb_set(jsonb, text, jsonb) does not exist
LINE 1: update polls set result = jsonb_set(result, ('{'||vote_to||'...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)
我怎样才能一次更新两个键?而且也是vote_count一个整数,所以我需要它进行双重转换才能使jsonb
vote_count::text::jsonb
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以做到这一点?
我正在一个用户应该能够将项目发布到列表的网站上工作.现在,当我尝试发布某些内容时,会出现错误信息
Failed to load resource: the server responded with a status of 422 (Unprocessable Entity).
Run Code Online (Sandbox Code Playgroud)
在控制台中点击它时,它会打开一个新的水龙头
Cannot GET /api/list
Run Code Online (Sandbox Code Playgroud)
它也在命令提示符中说
Unhandled rejection Error: Can't set headers after they are sent.
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会这样,我能做些什么来解决它?以下是我的代码的一些片段:
index.html的:
fetch('/api/list', options)
.then(response => response.json())
.then(response => {
if (response.status == 'OK') {
console.log('song is added')
getList(items)
} else {
alert(response.message)
}
})
}
Run Code Online (Sandbox Code Playgroud)
Server.js:
app.post('/api/list', userIsAuthenticated, (req, res) => {
let {
titleArtist
} = req.body
let user_id = req.session.user.id
// seaching for user id in database …Run Code Online (Sandbox Code Playgroud) 如何在不消除项目上的现有样式(例如颜色,文本对齐等)的情况下将样式元素附加到DOM?
该事件调用该函数,但问题是'Style'完全被替换为单个项目.
我在事件上触发了简单的代码:
function changeback(onoff) {
if(onoff) {
document.getElementById("field1").style.background="#fff";
} else
document.getElementById("field1").style.background="#000";
}
Run Code Online (Sandbox Code Playgroud) 这是一个程序,当我键入"kutty"它应该说我"你好kutty"但这个代码不起作用.
import java.util.*;
public class Kutty
{
public static void main(String args[])
{
byte a[]={5,2,3};
String c;
Scanner scan=new Scanner(System.in);
c=scan.next();
if(c=="kutty")
{
System.out.println("Hello" +c);
}
else
{
System.out.println("Invalid");
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使我的android构建过程自动化。为此,我想在XML文件中更改应用程序名称。代码是这样的
<resources>
<string name="app_name">Realta Connections</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
现在,我想在构建时用其他名称替换“ Realta Connections”名称,这是我将在构建时使用的名称。名称可以是“ Realta Connections”或其他任何名称,因此我需要检测名称为“ app_name”并替换其中的内容。我尝试寻找方法,但找不到确切的方法。我怎样才能做到这一点?请帮忙。
我是Google Compute Engine的新手.我想创建一个具有以下属性的Web服务器:
我创建了一个具有Linux Red Hat 7.1和机器类型的新实例,n1-standard-2它提供2个CPU内核和7.5 GB RAM.我可以准确定义一个具有100 GB HD和8 GB RAM的内核吗?如何定义SSH/SCP访问模式?
javascript ×3
angular ×2
css ×2
ant ×1
dom ×1
html ×1
java ×1
json ×1
jsonb ×1
linux ×1
postgresql ×1
react-native ×1
sql ×1
ssh ×1
state ×1
string ×1
typescript ×1
view ×1