angularjs - Passing parameter to isolated scope inside directive -
i trying pass 2 different parameter isolated scope inside directive.when log out values in console collapse getting true infocard getting false value.my question why getting false value infocard in advance.here directive.
<display-info user="user" collapse="true" infocard="true"></display- info>
in controller receiving 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 plunker link https://plnkr.co/edit/gng7e4rrvvg8wponqqrk?p=preview
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); } } });
Comments
Post a Comment