angularjs-ng-class

Angular apply class in directive

五迷三道 提交于 2020-01-30 08:36:24
问题 I have a angular directive which will produce bootstrap form-group, looks for $scope.errors for value of ng-model of the directive to show errors.. Example below: My html code: <input type="text" b-input ng-model="data.company.name" label="Company Name" class="form-control"/> and my directive code: app.directive('bInput', function ($compile) { return { restrict: 'EA', replace: true, link: function (scope, element, attrs) { var div = $('<div>', { 'class': 'form-group', 'ng-class': " 'has-error

Add a class selectively to an ng-repeat AngularJS

北城余情 提交于 2020-01-10 03:59:25
问题 I have an ng-repeat for a table, I want to be able to add a class when <td> is clicked, and remove the class when un-clicked. Multiple <td> can be selected at the same time. Right now ALL of the cities are or are not getting the class applies. For example: (lets say nodes has 100 items) <tr ng-repeat node in nodes> <td>{{node.name}}</td> <td>{{node.date}}</td> <td ng-click="toggleMe( node.city )" ng-class"{clicked : isClicked()}" >{{node.city}}</td> </tr> in my JS $scope.cityArr = []; $scope

angularjs show/hide tabs, click same tab hide the content

杀马特。学长 韩版系。学妹 提交于 2019-12-05 03:20:21
问题 when i click tab A, A content show when i click tab B, A content hide B content show but the effect i want is when i click tab A, A content show, click A tab again content hide. Any suggest will be help thanks <ul class="row text-center"> <li class="col col-33"> <a href="javascript:void(0);" ng-class="{selected: tab==a}" ng-click="tab = a ">a <i class="icon ion-arrow-down-b"></i></a> </li> <li class="col col-33"> <a href="javascript:void(0); " ng-class="{selected: tab==b}" ng-click="tab = b "

How to add and remove class with AngularJS?

给你一囗甜甜゛ 提交于 2019-12-04 01:24:32
问题 I have a few buttons that work like switchers. If you click one it becomes active and "shuts down" other buttons. I did this using jQuery but would like to use AngularJS. Here is my code: HTML <div class="button-bar"> <a class="button button-energized" id="weak">weak</a> <a class="button button-energized" id="normal">normal</a> <a class="button button-energized" id="strong">strong</a> </div> JavaScript .controller('AppCtrl', function($scope, $stateParams) { $('#weak').click(function() { $('

angularjs show/hide tabs, click same tab hide the content

流过昼夜 提交于 2019-12-03 20:24:17
when i click tab A, A content show when i click tab B, A content hide B content show but the effect i want is when i click tab A, A content show, click A tab again content hide. Any suggest will be help thanks <ul class="row text-center"> <li class="col col-33"> <a href="javascript:void(0);" ng-class="{selected: tab==a}" ng-click="tab = a ">a <i class="icon ion-arrow-down-b"></i></a> </li> <li class="col col-33"> <a href="javascript:void(0); " ng-class="{selected: tab==b}" ng-click="tab = b ">b <i class="icon ion-arrow-down-b"></i></a> </li> <li class="col col-33"> <a href="javascript:void(0);

Angular apply class in directive

本秂侑毒 提交于 2019-12-02 06:58:36
I have a angular directive which will produce bootstrap form-group, looks for $scope.errors for value of ng-model of the directive to show errors.. Example below: My html code: <input type="text" b-input ng-model="data.company.name" label="Company Name" class="form-control"/> and my directive code: app.directive('bInput', function ($compile) { return { restrict: 'EA', replace: true, link: function (scope, element, attrs) { var div = $('<div>', { 'class': 'form-group', 'ng-class': " 'has-error' : errors." + attrs.ngModel + " != null " }); $compile(div)(scope); element.wrap(div); if (attrs.label

Add a class selectively to an ng-repeat AngularJS

限于喜欢 提交于 2019-11-29 10:50:26
I have an ng-repeat for a table, I want to be able to add a class when <td> is clicked, and remove the class when un-clicked. Multiple <td> can be selected at the same time. Right now ALL of the cities are or are not getting the class applies. For example: (lets say nodes has 100 items) <tr ng-repeat node in nodes> <td>{{node.name}}</td> <td>{{node.date}}</td> <td ng-click="toggleMe( node.city )" ng-class"{clicked : isClicked()}" >{{node.city}}</td> </tr> in my JS $scope.cityArr = []; $scope.toggleMe = function(city) { if ($scope.count > 0) { angular.forEach($scope.cityArr, function(value) {