javascript - using ng-class in angular js -


i trying implement ng-class directive in angular , while doing bit stuck on it..

the below code snippet:-

<button ng-class="{discover_premium btn btn-lg:userlogin ==2,discover_connect_btn btn btn-lg:userlogin ==3}" >{{userlogin}}</button> 

i using following in controller:-

var currentmember= currentuserdata.query();      currentmember.$promise.then(function(response){          $scope.memberprofile = response.login_member_details;          var memberprofile = $scope.memberprofile;           if ($scope.memberprofile.type =="free")         {         $scope.userlogin = 2         }          else          {         $scope.userlogin = 3          }         }) 

so want implement different class different condition..

please me out newbie..

thanks lot

simply wrap class names single quotes

<button ng-class="{'discover_premium btn btn-lg': userlogin == 2, 'discover_connect_btn btn btn-lg': userlogin == 3}" >{{userlogin}}</button> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -