AngularJS 值在指令和模板中不可见- html
AngularJS values not visible in directive and template- html
我在 html 中有以下指令:
<as-excel-download institutionId="vm.reportInstitution.id"></as-excel-download>
指令如下所示:
(function() {
'use strict';
angular
.module('aposoft.common')
.directive('asExcelDownload', asExcelDownload);
function asExcelDownload() {
var directive = {
restrict: 'E',
scope: {
institutionId: '='
},
templateUrl: 'app/common/exceldownload/asExcelDownload.html'
};
return directive;
////////////
}
})();
指令模板如下所示:
<a href="/api/schedulerecordexcel/monthreport/{{institutionId}}">
<img src="./Excel.PNG" alt="icon" />
</a>
实际上我不知道为什么 {{institutionId}} 在指令模板 html 中是空的。
如果我在上述每个文件(这是控制器中的范围)中将 institutionId 更改为 vm 并在指令模板中通过 vm 访问机构 ID html 比一切正常。
有谁知道我在这里做错了什么?
我认为您使用了错误的名称作为属性,所以基本上这部分:
<as-excel-download institutionId="vm.reportInstitution.id"></as-excel-download>
应该是这样的:
<as-excel-download institution-id="vm.reportInstitution.id"></as-excel-download>
我在 html 中有以下指令:
<as-excel-download institutionId="vm.reportInstitution.id"></as-excel-download>
指令如下所示:
(function() {
'use strict';
angular
.module('aposoft.common')
.directive('asExcelDownload', asExcelDownload);
function asExcelDownload() {
var directive = {
restrict: 'E',
scope: {
institutionId: '='
},
templateUrl: 'app/common/exceldownload/asExcelDownload.html'
};
return directive;
////////////
}
})();
指令模板如下所示:
<a href="/api/schedulerecordexcel/monthreport/{{institutionId}}">
<img src="./Excel.PNG" alt="icon" />
</a>
实际上我不知道为什么 {{institutionId}} 在指令模板 html 中是空的。 如果我在上述每个文件(这是控制器中的范围)中将 institutionId 更改为 vm 并在指令模板中通过 vm 访问机构 ID html 比一切正常。 有谁知道我在这里做错了什么?
我认为您使用了错误的名称作为属性,所以基本上这部分:
<as-excel-download institutionId="vm.reportInstitution.id"></as-excel-download>
应该是这样的:
<as-excel-download institution-id="vm.reportInstitution.id"></as-excel-download>