小编kir*_*dla的帖子

根据角度的路径变化添加或删除类

在此输入图像描述我有3条路线包含3种形式我试图在当前选项卡上根据当前路径设置自举活动类.我使用了角度路由模块.我怎样才能做到这一点.我附上js代码,请检查并帮助

            angular.module('bankAppOnline',     ['ngSanitize','ngRoute','ngAnimate','ngQuantum'])
                .config(['$routeProvider',
                    function($routeProvider) {
                        $routeProvider.
                        when('/firststep', {
                            templateUrl: 'templates/firstformtemplate.html',
                            controller: 'firstformCtrl',
                            containerClass: 'active'

                        }).
                        when('/secondstep', {
                            templateUrl: 'templates/secondformtemplate.html',
                            controller: 'secondformCtrl',
                            containerClass: 'active'


                        }).
                        when('/thirdstep', {
                            templateUrl: 'templates/thirdformtemplate.html',
                            controller: 'thirdformCtrl',
                            containerClass: 'active'

                        }).
                        otherwise({
                            redirectTo: '/firststep'
                        });
                    }])
               .run(function($rootScope){

                $rootScope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams){
                    console.log(event);
                    console.log(toState);
                    console.log(fromState);
                    console.log(toParams);
                    $rootScope.containerClass = toState.containerClass;
                });

            })
                .controller('Main-Ctrl',function($scope)
            {
                $scope.containerClass =  "active";
            })
                .controller('firstformCtrl', function ($scope, Customer) {

                   $scope.cities = ['Hyderabad','Vizag','Vijayawada','Bangalore','Delhi','Mumbai','Chennai','Noida','Pune','Tirupathi'];
                   $scope.professions = ['Doctor','Teacher','Engineer','Lawyer'];
                   $scope.customer = Customer.get();
                 $scope.reset = function() {


                    $scope.firstform.$setPristine();
                       var …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-route-segment

3
推荐指数
1
解决办法
4703
查看次数

隐藏/显示具有相同类名的元素

我遇到的问题是根据孩子的内容选择(隐藏/显示)列表项

我无法添加或更改ID或类(这些由crm设置并且会有所不同)

我需要根据所选内容隐藏/显示信息.例如."隐藏包含类别'Title'的子div中包含'Accommodation Type'字样的列表项"

因此它会隐藏此列表项:请仅隐藏子div中列出具有住宿类型的项目.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>New Web Project</title>
            <script src="jquery.min.js"></script>
            <script>
            $(document).ready(function()
            {
                $("li").
                var title = $("li").find('div[class=Title]').html();        
                if(title == "Accommodation Type")
                {
                    $('div[class=Title]').parent().parent().hide();
                }

            });
            </script>

        </head>
        <body>
            <ul>
    <li>
    <div class="Group">
    <div class="Title">Accommodation Type</div>
    <div class="Item">
    <select>
    <option value="">-- Please select --</option>
    <option value="30393382">Motel</option>
    <option value="30393383">Hotel</option>
    </select>
    </div>
    </div>
    </li>
    <li>
    <div class="Group">
    <div class="Title">Adults</div>
    <div class="Item">
    <select>
    <option value="">-- Please select …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

2
推荐指数
1
解决办法
805
查看次数