Is AngularJS just for single-page applications (SPAs)?

后端 未结 5 1247
轮回少年
轮回少年 2020-11-29 15:21

We are looking at options to build the front end of an application we are creating and are trying to evaluate a tool that will work for us and give us the best platform to m

5条回答
  •  余生分开走
    2020-11-29 15:35

    If all you need is a few pages with client databinding, I'd go with Knockout and Javascript Namespacing.

    Knockout is great, especially if you need uncomplicated backward compatibility and have fairly straight forward pages. If you're using 3rd party components, Knockout's custom bindings are straightforward and easy to work with.

    Javascript namespacing allows you to keep your code separate and manageable.

    var myCo = myCo || {};
    myCo.page = {
        init: function(){ ... },
        ...
    }
    

    And in a script tag after your other scripts are loaded

    
    

    The key is, you use whatever tool you want for when you need it. Need databinding? Knockout (or whatever you like). Need routing? sammy.js (or whatever you like).

    Client code can be as simple or complicated as you want it. I tried integrating Angular into a very complicated site with an existing proprietary framework, and it was a nightmare. Angular is great if you're starting fresh, but it has a learning curve and locks you into a very tight workflow. If you don't follow it, your code can get really tangled really fast.

提交回复
热议问题