angular.js - angular何时用directive、controller、service
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-15 16:52:58
0
1
621
var $ele = $('#container');

$ele.on('click', function (e){
    var $t = $(e.target);

    if($t.is('.file')){
        openDoc($t);
    }

    if($t.is('.nav a')){
        changeViewTo($t.attr('index'));
    }
})

function openDoc(){
    $ele......
}

function changeViewTo(){
    $ele......
}

上面这段代码如何分布在directivecontrollerservice
openDocchangeViewTo都操作$ele及其子元素

要求:
1、需要对外暴露openDocchangeViewTo方法。

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
小葫芦

When it is necessary to expand the original html标签的功能的时候用directive
It is used when you need to transfer data between different controllers, or when you want to retain a global variable, because it has only one instance globallyservice The controller should be simple and does not need to place too much logic. It is responsible for the connection between the view and the model

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!