0

I am trying to pass two different parameter to isolated scope inside directive.When I log out values in console then for collapse I am getting true but for infoCard I am getting false value.My question is why I am getting false value for infoCard Thanks in advance.Here is my directive.

<display-info user="user" collapse="true" infoCard="true"></display- info> 

In my controller i am receiving the parameter,

angular.module('myApp').directive('displayInfo', function() { return { templateUrl: "displayInfo.html", restrict: "EA", scope: { user: '=', initialCollapse:'@collapse', showInfo:'@infoCard' }, controller: function($scope) { $scope.collapse = ($scope.initialCollapse === 'true'); $scope.infoCard = ($scope.showInfo === 'true'); console.log("collapse---->",$scope.collapse); console.log("displyInfo---->",$scope.infoCard); } } }); 

Here is plunker link https://plnkr.co/edit/Gng7e4RRVvg8wPOnqQrk?p=preview

1 Answer 1

1

camel case convention have problem in directive

Try this.

<display-info user="user" collapse="true" test="true"></display-info> angular.module('myApp').directive('displayInfo', function() { return { templateUrl: "displayInfo.html", restrict: "EA", scope: { user: '=', initialCollapse:'@collapse', showInfo:'@test' }, controller: function($scope) { $scope.collapse = ($scope.initialCollapse === 'true'); $scope.infoCard = ($scope.showInfo === 'true'); console.log("collapse---->",$scope.collapse); console.log("displyInfo---->",$scope.infoCard); } } }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.