Architecture for single page application (JavaScript)

前端 未结 7 2017
旧时难觅i
旧时难觅i 2020-12-15 10:27

I wanted to understand the overall architecture for designing single page application (mainly through JavaScript)

Let\'s say I have a login page (Usernam/Password) a

7条回答
  •  心在旅途
    2020-12-15 11:10

    You need index.html page like below

    
      
         
          
    ...

    When application loaded, all views (divs with view class) are hidden (display:none) except login view. Login view should have login form on it, when it submitted by user it initiates ajax request. When ajax successful application hides login page and displays home page instead.

    You may structure your code next way. For every module you will have model, view and controller files.

    For example, for login module you may have loginModel.js, loginView.js, loginCtrl.js. In model file you will connect to DB and check credentials provided. In view you will bind listeners to controls. In controller you will react to user pressed Submit button.

提交回复
热议问题