Reputation: 3009
I have a directive like below,
.directive('lbd', function () {
return {
restrict: 'E',
scope: {
context: '=',
dui: '='
},
}
});
Calling template,
<lbd class="col-xs-12 lbd" context="disease-description" dui="id"></lbd>
I am giving id fro my controller as,
$scope.id = "222";
But the directive is not rendered.I am not able to find the solution.Can anyone please help me.Thanks.
Upvotes: 0
Views: 249
Reputation: 17289
I think you have a mistake in your directive
. remove ,
after scope
body.
and disease-description
should be =
scope such as $scope.id
.
But i think disease-description
is as string
so change context
type to @
in directive.
.directive('lbd', function () {
return {
restrict: 'E',
scope: {
context: '@',
dui: '='
}
}
});
var app = angular.module('anApp', []);
app.controller('ctrl', function($scope) {
$scope.id = "222";
});
app.directive('lbd', function () {
return {
restrict: 'E',
scope: {
context: '@',
dui: '='
},
template:"<p>{{dui}},{{context}}</p>"
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script>
<div ng-app="anApp" ng-controller="ctrl">
<lbd class="col-xs-12 lbd" context="disease-description" dui="id"></lbd>
</div>
Upvotes: 1