Angularjs 在同一控制器内重复使用模板两次,但显示不同的数据

Angularjs 在同一控制器内重复使用模板两次,但显示不同的数据,angularjs,Angularjs,我有一个html文件,我想包含在两个地方,如: <div ng-if="flag1" ng-include = templatepath></div> <div ng-if="flag2" ng-include = templatepath></div> template.html 名称为{{Name} 单击运行函数时,flag1和flag2会发生更改。 我希望名称包含不同的值。但是,当我在控制器中更改名称时,两行都会更改。我能做什么?使用组件

我有一个html文件,我想包含在两个地方,如:

<div ng-if="flag1" ng-include = templatepath></div>
<div ng-if="flag2" ng-include = templatepath></div>
template.html
名称为{{Name}
单击运行函数时,flag1和flag2会发生更改。 我希望名称包含不同的值。但是,当我在控制器中更改名称时,两行都会更改。我能做什么?

使用组件:

<my-component name="name1"></my-component>
<my-component name="name2"></my-component>

app.component(“myComponent”{
绑定:{name:'
<my-component name="name1"></my-component>
<my-component name="name2"></my-component>
app.component("myComponent", {
    bindings: { name: '<' },
    templateUrl: 'template.html'
})
<h2> Name is {{$ctrl.name}} </h2>