user3318489 user3318489 - 1 year ago 139
AngularJS Question

AngularJS values not visible in directive and template- html

I have the following directive in html:

<as-excel-download institutionId=""></as-excel-download>

the directive looks like this:

(function() {
'use strict';

.directive('asExcelDownload', asExcelDownload);

function asExcelDownload() {
var directive = {
restrict: 'E',
scope: {
institutionId: '='
templateUrl: 'app/common/exceldownload/asExcelDownload.html'
return directive;


and the directive template looks like this:

<a href="/api/schedulerecordexcel/monthreport/{{institutionId}}">
<img src="./Excel.PNG" alt="icon" />

and actually I don't know why {{institutionId}} is emty in directive template html.
If I change institutionId into vm in every of the above files (which is the scope in controller) and access institution id over vm in directive template html than everything works fine.
Does anyone know what I am doing wrong here?

Answer Source

I think you are using wrong name as attribute, so basically this part:

<as-excel-download institutionId=""></as-excel-download>

Should look like this:

<as-excel-download institution-id=""></as-excel-download>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download