Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 两个不同的角度指令会出现相同的模板_Javascript_Angularjs - Fatal编程技术网

Javascript 两个不同的角度指令会出现相同的模板

Javascript 两个不同的角度指令会出现相同的模板,javascript,angularjs,Javascript,Angularjs,我调用了两个单独的角度指令(请参见下面的标记),但最后一个模板始终是在下面的标记部分中为两个指令显示的模板 如您所见,我为两个指令(在下面的指令部分)设置了不同的templateUrl,但是标记部分(attachment modal.html)中的最后一个始终是出现的 如果我将download-modal.html设置为最后一个,那么该模板将为这两个指令显示。在每个指令中放置断点也可以看出这一点。您在标记中定义的第一个指令,即使被单击,也不会执行 两个模板中都有不同的标记。如果我注释掉其中一条指

我调用了两个单独的角度指令(请参见下面的标记),但最后一个模板始终是在下面的标记部分中为两个指令显示的模板

如您所见,我为两个指令(在下面的指令部分)设置了不同的templateUrl,但是标记部分(attachment modal.html)中的最后一个始终是出现的

如果我将download-modal.html设置为最后一个,那么该模板将为这两个指令显示。在每个指令中放置断点也可以看出这一点。您在标记中定义的第一个指令,即使被单击,也不会执行

两个模板中都有不同的标记。如果我注释掉其中一条指令,那么与该指令相关联的模板将同时用于这两条指令

在操纵标记之后,无论我做了什么,无论哪个指令是后一个指令,都是执行的指令。

看起来我不能在同一个网页上有两个指令,因为只有在标记中定义的最后一个指令会被执行

我在IE和Chrome上都试过了

我需要做什么才能为每个指令生成相关模板?

加成
检查存款抬头信息
',
链接:功能(范围、元素、属性、控制器){
scope.open=函数(){
$modal.open({
templateUrl:root+“AccountingModule/modal/attachment/attachment modal.html”,
尺寸:'md',
背景:没错,
控制器:[“属性”,函数(属性){
var viewModel=此;
viewModel.attributes=属性;
}],
controllerAs:'attachCtrl',
决心:{
属性:函数(){
返回属性;
}
}
});
}
}
}
}])
.directive('download',['$modal',function($modal){
返回{
限制:'E',
排除:错误,
替换:正确,
模板:“”,
链接:功能(范围、元素、属性、控制器){
scope.open=函数(){
$modal.open({
templateUrl:root+“AccountingModule/modal/attachment/download modal.html”,
尺寸:'md',
背景:没错,
控制器:[“属性”,函数(属性){
var viewModel=此;
viewModel.attributes=属性;
}],
controllerAs:“downloadCtrl”,
决心:{
属性:函数(){
返回属性;
}
}
});
}
}
}
}])

对于指令中的ng click事件,我需要为每个打开的作用域指定不同的名称

例如,scope.open函数的openattachments&opendownloads,因为scope是一个全局变量,最后一个变量总是重写第一个变量

template: '<a style="padding-right: 5px" class="pull-right" href="#" ng-click="openattachments()"><i class="fa fa-files-o fa-lg" style="padding-right: 5px"></i>Attachment</a>',
模板:“”,

你能展示这两个模板吗?我为这个问题添加了模板……我还有一个angularjs问题。你愿意对此发表评论吗?发布答案的用户没有详细说明就离开了。以下是链接:
<p>For Testing Purpose: Download Type: {{downloadCtrl.attributes.downloadType}}</p>
<p>For Testing Purpose: ID: {{downloadCtrl.attributes.downloadId}}</p>

    <div class="modal-header">
        <h3 class="modal-title">File Download</h3>
    </div>

    <div class="modal-footer">
        <div class="btn-toolbar pull-right" role="toolbar">
            <div class="btn-group" role="group" >
                <button type="button" class="btn btn-default" file-download download-type={{downloadCtrl.attributes.downloadType}} download-id={{downloadCtrl.attributes.downloadId}}>Download files</button>
            </div>
            <div class="btn-group" role="group">
                <button type="button" class="btn btn-default" ng-click="$close()">Close</button>
            </div>
        </div>
    </div>
<p>For Testing Purpose: Attachment Type: {{attachCtrl.attributes.attachmentType}}</p>
<p>For Testing Purpose: ID: {{attachCtrl.attributes.attachmentId}}</p>

<div class="modal-header">
    <h3 class="modal-title">File Attachment</h3>
</div>

<div class="modal-body">
    <input type="file" id="inpFile" file-model="myFile" />
</div>

<div class="modal-footer">
    <div class="btn-toolbar pull-right" role="toolbar">
        <div class="btn-group" role="group" >
            <button type="button" class="btn btn-default" file-upload attachment-type={{attachCtrl.attributes.attachmentType}} attachment-id={{attachCtrl.attributes.attachmentId}}>Upload</button>
        </div>
        <div class="btn-group" role="group">
            <button type="button" class="btn btn-default" ng-click="$close()">Close</button>
        </div>
    </div>
</div>
.directive('attachment', ['$modal', function($modal) {
  return {
    restrict: 'E',
    transclude: false,
    replace: true,
    template: '<a style="padding-right: 5px" class="pull-right" href="#" ng-click="open()"><i class="fa fa-files-o fa-lg" style="padding-right: 5px"></i>Attachment</a>',
    link: function(scope, elem, attrs, controller) {
      scope.open = function() {
        $modal.open({
          templateUrl: root + 'AccountingModule/modal/attachment/attachment-modal.html',
          size: 'md',
          backdrop: true,
          controller: ['attributes', function(attributes) {
            var viewModel = this;
            viewModel.attributes = attributes;
          }],
          controllerAs: 'attachCtrl',
          resolve: {
            attributes: function() {
              return attrs;
            }
          }
        });
      }
    }
  }
}])

.directive('download', ['$modal', function($modal) {
  return {
    restrict: 'E',
    transclude: false,
    replace: true,
    template: '<a style="padding-right: 5px" class="pull-right" href="#" ng-click="open()"><i class="fa fa-files-o fa-lg" style="padding-right: 5px"></i>Download</a>',
    link: function(scope, elem, attrs, controller) {
      scope.open = function() {
        $modal.open({
          templateUrl: root + 'AccountingModule/modal/attachment/download-modal.html',
          size: 'md',
          backdrop: true,
          controller: ['attributes', function(attributes) {
            var viewModel = this;
            viewModel.attributes = attributes;
          }],
          controllerAs: 'downloadCtrl',
          resolve: {
            attributes: function() {
              return attrs;
            }
          }
        });
      }
    }
  }
}])
template: '<a style="padding-right: 5px" class="pull-right" href="#" ng-click="openattachments()"><i class="fa fa-files-o fa-lg" style="padding-right: 5px"></i>Attachment</a>',