angularjs ng-switch


    <p>
        <a href="#" ng-click="toggle()">Toggle Sectiona>
    p>

    <div ng-switch="section">

        <p ng-switch-when="happy" bn-directive>
            Oh sweet!
        p>

        <p ng-switch-when="sad" bn-directive>
            Oh noes!
        p>

    div>

js

var app = angular.module( "Demo", [] );

        // 定义控制器
        app.controller(
            "DemoController",
            function( $scope ) {

                $scope.section = "happy";


                //在toggle函数中改变section的值,以此在标记中显示/隐藏不同的部分
                $scope.toggle = function() {

                    if ( $scope.section === "happy" ) {

                        $scope.section = "sad";

                    } else {

                        $scope.section = "happy";

                    }

                };

            }
        );