我如何在angularJs中添加CSS样式?

时间:2015-05-07 04:58:35

标签: javascript angularjs

<ul class="nav nav-pills tabscount">
        <li ng-repeat="section in submissionCtlr.submissionForm.sections" ng-class="{ active:submissionCtlr.isSelected(section.sectionId) }" > <a href="" ng-click="submissionCtlr.selectTab(section.sectionId)">{{section.sectionName}}</a></li>
    </ul>

    <input type="submit" value="Submit" style="display:none" class="btn btn-primary" ng-click="submissionCtlr.submitForm()" ng-disabled="submitForm.$invalid">

this.tab=1;
this.selectTab = function(setTab){
 var tabcount = $scope.submissionCtlr.submissionForm.sections.length;
 if(this.tab != tabcount){
     this.tab++;
 }else {

 }

点击下一步按钮我算了,李计数结束时需要提交。提交应显示,接下来应显示:无。我怎样才能在anugularJs中实现。

2 个答案:

答案 0 :(得分:0)

您可以使用ng-show告知当前标签(tab)是否与标签总数(submissionCtlr.submissionForm.sections.length)相同。

<input type="submit" value="Submit" ng-show="submissionCtlr.tab==submissionCtlr.submissionForm.sections.length" class="btn btn-primary" ng-click="submissionCtlr.submitForm()" ng-disabled="submitForm.$invalid">

答案 1 :(得分:0)

用于修改angularjs中的DOM元素。正确的方法是创建一个指令并访问该指令中的元素。 例如 -

<button  class="btn btn-primary" ng-click="submit()" on-submit> Submit </button>

JS:

 angular.module('myApp')
    .directive('onSubmit', ,function() {
      return {
        restrict: 'A',
        link: function($scope,el) {

              $scope.submit = function() {
                          el[0].css("display", "none");  //change the css here accordingly.
                        }     

        }

     };

    });

您还可以添加类

element.addClass('myclass');