Javascript 如何将脚本编码转换为angularJS编码

Javascript 如何将脚本编码转换为angularJS编码,javascript,angularjs,angularjs-directive,angular-ui-router,angularjs-scope,Javascript,Angularjs,Angularjs Directive,Angular Ui Router,Angularjs Scope,这是我为左侧菜单左右滑动编写的脚本。我想把它转换成angularJS,我是从其他网站复制的,无法理解 <script> var menuLeft = document.getElementById('cbp-spmenu-s1'), showLeftPush = document.getElementById('showLeftPush'), body = document.body; showLeftPush.onclick =

这是我为左侧菜单左右滑动编写的脚本。我想把它转换成angularJS,我是从其他网站复制的,无法理解

<script>
    var menuLeft = document.getElementById('cbp-spmenu-s1'), 
        showLeftPush = document.getElementById('showLeftPush'),
        body = document.body;

    showLeftPush.onclick = function() {
        classie.toggle(this, 'active');
        classie.toggle(body, 'cbp-spmenu-push-toright');
        classie.toggle(menuLeft, 'cbp-spmenu-open');
        disableOther('showLeftPush');
    };

    function disableOther(button) {
        if (button !== 'showLeftPush') {
            classie.toggle(showLeftPush, 'disabled');
        }
    }
</script>

var menuLeft=document.getElementById('cbp-spmenu-s1'),
showLeftPush=document.getElementById('showLeftPush'),
body=document.body;
showLeftPush.onclick=函数(){
类别切换(此为“活动”);
类别切换(主体,“cbp spmenu向右推”);
类别切换(菜单栏“cbp spmenu open”);
禁用其他(“showLeftPush”);
};
功能禁用其他(按钮){
如果(按钮!=“showLeftPush”){
类别切换(showLeftPush,“禁用”);
}
}

我可以看出此代码是某种切换功能。所以,让我来解释一下我们如何转换这个

代码开始于
onclick
,因此在angular中单击
ng
,也可以在angular中这样在HTML中编写

<button id="showLeftPush" ng-click="test=!test;" ng-init="test=false;" ng-class="{'active': test, 'disabled': test}"></button>
ID为的Div-cbp-spmenu-s1:

<body ng-class="{'cbp-spmenu-push-toright': test}" ng-controller='MyController' ng-app="myApp">
<div id="cbp-spmenu-s1" ng-class="{'cbp-spmenu-open': test}">left</div>
请以此为起点,继续构建你的angular应用程序

我已经包括了一个演示供您参考