问题标签 [angular2-components]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angular - 如何以编程方式更改已渲染组件的输入值(Angular 2)
在我的 Angular 2 应用程序中,我有一个组件(mainComp),其中包括另一个组件
my-comp发出(在选择/单击时)它的值(它是一个自定义下拉列表)通过
mainComp
接收下拉列表的值
angular - Angular 2: Add components at specific/nth position dynamically
Unable to add components at specific index. Below the plunker link for example. PlunkerAddRemoveComponents
Here, I am able to add components at a specific index at the first time only.
My Scenario is:
- Click on Add Component button 3 times. It will create 3 rows continuously.
- Then click on second row Add button, it will create another row.
- And again click on the same button, it will create component next one row
Here, is the problem, I want to create component at every time next to Add button row.
javascript - Angular2: provide current route to parent component
To start with: The application I build at the moment is an Angular2(RC3) one (with the @angular/routerv3.0.0-alpha.8 module).
This app consists of a parent component including different header components which should be selected according to the current route. In short:
In the parent components template there is a switch which looks like:
Where dataStore in the parent component is defined as:
All my efforts so far didn't result in a working solution. I tried to create a routeStore which provides a custom Observable and looks like this:
This part is able to provide data to the parent when I navigate to another route via a button click like:
But as soon as I refresh the page or initialize the app it throws the
error.
Also my effort to handle all routing changes inside the parent component only by using the router like
didn't result in an acceptable result, as the path property of the urlPathArray is always returning an empty string (meaning the route of the parent component).
How can I get the currently active route to be passed to the parent components dataStore objects currentRoute property to rerun the ngSwitch statement and display the correct header?
angular - 组件间对象的双向数据绑定
我有输入组件:
MyInputComponent 的模板
我想在内部设置过滤器输入并对外部 Component 对象产生影响。
如何将过滤器对象传入MyInputComponent
以实现2路数据绑定?
我想实现类似 [(ngModel)]="filter.value" 但在组件之间工作
这里关于 2-way 数据绑定的其他帖子没有回答我的问题。
编辑:
extends DefaultValueAccessor
在我的 MyInputComponent 中使用后,我的父组件输入消失,没有任何错误。
angular - 通用类型'ComponentRef' 需要 1 个类型参数
无法删除 ionic-2 中的动态组件。打字稿编译时说异常
“通用类型 'ComponentRef' 需要 1 个类型参数”。
此外,在不使用 ionic2 的情况下使用相同的代码。非常感谢您的帮助。提前致谢。
例外:TypeScript 错误:....../home/home.ts(9,11): Erro r TS2314: Generic type 'ComponentRef' 需要 1 个类型参数。
angular - Angular 2 Provider 的类似物
我有一个用于复选框的自定义组件。
据我了解,RC3 Provider 被标记为已弃用。我必须如何重写我的组件以便他在下次更新后工作?
javascript - Angular2:我们可以在模板中插入哪些表达式
我读到我们可以插入 Javascript 表达式。我们可以插入的有效 Javascript 表达式列表是什么?到目前为止,对于插值,我有一个显示的属性,例如。object.property
, 简短的表达式,比如{{1+1}}
我们还可以插入什么 Javascript 表达式?
angular - 角度2:使用动态组件将所有输入值传递给其他组件,同时单击提交按钮
我创建了多个带有一些输入字段的动态组件。现在,我想在单击提交按钮时将所有输入值发送到其他组件。
情景是,
- 单击添加按钮 5 次。现在,它将使用输入字段创建 5 行
- 然后,点击提交按钮,它会提醒所有输入值。在这里,我尝试使用@Input/@Output 但我无法使其运行的问题。
你能帮我解决这个问题吗?
非常感谢您的支持。提前致谢。
angular - 如何使用动态模板创建组件?(使用内联模板嵌入组件)
我正在尝试创建一个内部具有动态模板字符串的组件,该字符串可以访问模板上的局部变量。我尝试过的每种方法都以“动态模板字符串”结束$compile
(请原谅我是角度 1 术语)。
这是下面组件的代码。在您看到评论的地方,我想插入一个可以item
在ngFor
.
理想情况下,我希望ion-alpha-scroll
在item
. ngFor
我尝试ng-content
在必要ngFor
的组件中使用但没有运气 -
我试过的一件事是这样的 -
这alphaScrollTemplate
只是一个包含{{item.$t}}
. 然后我尝试在评论提出问题的组件中引用它,但它不起作用 -
我真的很好奇这是否可以用 angular 2 来实现。我刚刚发现这个问题与我的非常相似。任何帮助或建议将不胜感激,谢谢。