简体   繁体   English

在Angular中处理另一个组件内的组件

[英]Handling Components Inside another Component in Angular

I am trying to leverage the concept of Component Based Architecture(CBA) in Angular. 我正在尝试利用Angular中基于组件的体系结构(CBA)的概念。 Following is the scenerio: 以下是场景:

I have three components with different selectors. 我有三个具有不同选择器的组件。 Now, Inside another 4th component, I am trying to import them. 现在,在另一个第4组件中,我正在尝试导入它们。 This is done by adding their selectors in the laters html file. 这是通过在更高版本的html文件中添加其选择器来完成的。

4th Component File: component.html 第四个组件文件:component.html

<component1></component>
<component2></component>
<component3></component>
<component4></component> 

All the subcomponents are basically bootstrap tables with data. 所有的子组件基本上都是带有数据的引导表。

Moreover, I am using ngb-pagination to provide pagination in these components. 此外,我正在使用ngb-pagination在这些组件中提供分页。

Now the problem is that whenever I click the sort favicon, the control of the page is transferred to the sub-component's URL which means the entire page is changed. 现在的问题是,每当我单击排序图标时,页面的控件就会转移到子组件的URL,这意味着整个页面都会被更改。 Now, we need to click the favicon again to make the sort appear. 现在,我们需要再次单击该图标,以使排序出现。

Same problem persists when you change the page number. 更改页码时,同样的问题仍然存在。 It might be because angular needs the components URL to make a get query with pageable options. 可能是因为angular需要组件URL来进行带有可分页选项的get查询。

I am using Jhiptser. 我正在使用Jhiptser。

Please let me know if there is a way around.. 请让我知道是否有办法。

Following are the screenshots: 以下是屏幕截图:

This is the main Component which has other components like deployment and rollout: 这是主要组件,具有其他组件,如部署和部署:

在此处输入图片说明

This is the subcomponent. 这是子组件。

Now, whenever I click the sort button (any button) from the main component page, the first click doesnt actually perform the action. 现在,每当我从主组件页面单击排序按钮(任何按钮)时,第一次单击实际上都不会执行该操作。 It takes to to the sub components page. 转到子组件页面。 After that, the functionality is working as expected. 之后,该功能将按预期工作。

The solution is pretty simple. 解决方案非常简单。

Jhipster, by default uses ngb-pagination module for handling pagination.(Server Side). Jhipster默认情况下使用ngb -pagination模块来处理分页。(服务器端)。

Using a more popular module like ngx-pagination simply does the job. 使用像ngx-pagination这样更流行的模块就可以完成任务。 All we need to do is simply add some pagination controls. 我们需要做的就是简单地添加一些分页控件。

This problem is somehow linked to this open issue . 这个问题与这个未解决的问题有某种联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM