-4

There is a web project use Java as backend & html5 as front-end.

In a single signin feature, there are several static html pages:

  • signin.html, get user info,
  • signin_confirm.html, tip signin succeed, and need check email to confirm signin,
  • signin_confirm_succeed.html, succeed to confirm,
  • signin_confirm_expired.html, tip when error click an expired confirm link,
  • signin_confirm_failed.html, failed to confirm, due to email not exists or confirm code not match,

Obviously, this is not a good approach, I want to reduce count of static html to 1 or 2 pages for this feature, and more features to be developed.

What js library do you think is suitable to do that job?

Eric
  • 22,183
  • 20
  • 145
  • 196

1 Answers1

2

In a recent project I've used AngularJS, I came across the same question. What I've done then was using ui-router to simply add a main content-div into my html-file, which would provide me a 'include' like behaviour. For little addings, like <section>s or <div>s, I've used my own directives. At the end you are able to provide external html templates through a directive into your main view, gathering up all together and setting up your final view - dynamically.

Here's a pretty neat example of how to use custom directives: http://www.ng-newsletter.com/posts/directives.html

Aer0
  • 3,792
  • 17
  • 33
  • Good idea, I have considered `AngularJS`, but it feels super un-intuitive to me, I want something similar but simpler & intuitive. – Eric Jan 13 '16 at 09:14
  • Actually, Angular is kind of different, compared to other front end frameworks. But the moment you get used to it and it's huge feature set, you may fell in love (or even start hating it). For me, compared to Backbone what I've been using before, Angular is far better. – Aer0 Jan 13 '16 at 09:39