如何将属性从父组件传递到其子组件的类构造函数Angular 2?
计算出一半的神秘感,因为属性可以毫无问题地传递给视图.
import {Component, View, bootstrap} from 'angular2/angular2';
import {Example} from 'client/example';
@Component({
selector: 'app'
})
@View({
template: `<p>Hello</p>
<example [test]="someAttr"
[hyphenated-test]="someHyphenatedAttr"
[alias-test]="someAlias"></example>
`,
directives: [Example]
})
class App {
constructor() {
this.someAttr = "attribute passsed to component";
this.someHyphenatedAttr = "hyphenated attribute passed to component";
this.someAlias = "attribute passed to component then aliased";
}
}
bootstrap(App);
Run Code Online (Sandbox Code Playgroud)
import {Component, View, Attribute} from 'angular2/angular2';
@Component({
selector: 'example',
properties: ['test', 'hyphenatedTest', 'alias: aliasTest']
})
@View({
template: `
<p>Test: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用CodePipeline和GitHub设置AWS CloudFormation配置。
我在自己的示例项目和教程中都失败了:使用AWS CloudFormation创建GitHub Pipeline。
创建了所有资源,但是在CodePipeline中,我在初始“源”阶段不断收到以下错误。
Could not fetch the contents of the repository from GitHub.
见下图:
请注意,这不是权限错误。到目前为止,这是Google尚不存在的其他功能。
如果我停止使用CloudFormation并通过控制台创建CodePipeline,则可以将GitHub配置为可以工作,但是出于我的目的,我需要使用CloudFormation。需要坚持使用模板。
这是从教程复制的CloudFormation模板中的模板:
Parameters:
BranchName:
Description: GitHub branch name
Type: String
Default: master
RepositoryName:
Description: GitHub repository name
Type: String
Default: test
GitHubOwner:
Type: String
GitHubSecret:
Type: String
NoEcho: true
GitHubOAuthToken:
Type: String
NoEcho: true
ApplicationName:
Description: CodeDeploy application name
Type: String
Default: DemoApplication
BetaFleet:
Description: Fleet configured in CodeDeploy
Type: String
Default: DemoFleet
Resources:
CodePipelineArtifactStoreBucket:
Type: "AWS::S3::Bucket"
CodePipelineArtifactStoreBucketPolicy:
Type: "AWS::S3::BucketPolicy" …Run Code Online (Sandbox Code Playgroud) 使用流星:
我在Messages中有一个消息列表,用于存储userId.
Messages = new Mongo.Collection('messages');
// example of message data:
{
authorId: 'XFdsafddfs1sfd', // corresponding to a Meteor.userId
content: 'some Message'
}
Run Code Online (Sandbox Code Playgroud)
我正在发布消息和现有用户.
Meteor.publish('messages', function () {
return Messages.find({});
});
Meteor.publish('users', function () {
return Meteor.users.find({});
});
Run Code Online (Sandbox Code Playgroud)
目前,我可以获取消息列表并根据userIds添加用户名.由于用户可以更改其用户名和配置文件信息,因此将用户数据添加到集合中只是userIds是没有意义的.
var messages = Messages.find({}).fetch();
var messages.forEach(function(message) {
message.username = Meteor.users.find(message.authorId).fetch() [0].username; // ugly
});
Run Code Online (Sandbox Code Playgroud)
此代码有效,但涉及大量浪费的调用.我想知道如何以更好的方式实现这一目标.
在Meteor中,将用户数据与包含userIds的集合配对的最有效和最干净的方法是什么?
我目前正在使用以下软件包处理运行Meteor 1.1.0.2 的项目:
meteor-platform
angular:angular2
netanelgilad:angular2-typescript
Run Code Online (Sandbox Code Playgroud)
我遇到了令人沮丧的问题.当我创建模板时:
/someTemplate.ng.html
<h1>Hello World</h1>
<!-- displays: Hello World -->
Run Code Online (Sandbox Code Playgroud)
它会运行.但是在对该模板的后续更改中,它将不会更新.
/someTemplate.ng.html
<h1>Hello Somebody</h1>
<!-- displays: Hello World -->
Run Code Online (Sandbox Code Playgroud)
情况并非总是如此,但我不确定是否或可能导致此问题的变化.
似乎模板正在缓存,因此不会更新.正如您可以想象的那样,这会带来令人沮丧的开发体验.
相同的命名模板甚至可以跨不同的应用程序缓存.
如果我启动一个新项目,指向相同的模板名称,它将获取旧模板.
/someTemplate.ng.html
<h1>New Meteor Project</h1>
<!-- displays: Hello World -->
Run Code Online (Sandbox Code Playgroud)
有关问题是特定于包还是与Meteor相关的任何想法.还有其他人遇到过同样的问题吗?任何快速/硬盘修复?