, the conventional TP can be directly foreach, but with angular it must be written like this:
This will write the data in JS, SQL out of the data how to allocate it, not to find themselves uncomfortable?
Then why are so many people using angular, where is she?
Learning not to learn ANGULARJS is not the focus, the focus is to learn the set of MVVM logic (which will explain what this is), and angular is just the most mature solution, so many people will suggest you learn angularjs, in fact, there are ember, Aurelia and so on, are great for the MVVM framework.
As an example (ANGULARJS):
As you write the data, if you use jquery, you need this:
//foo is Arrayfoo.forEach(function(eachFoo){ $ul.append('' + eachFoo + '');});
and Angularjs needs to be written in HTML, which is the command:
It is obvious that jquery will be more convenient if you do not continue to deal with the Foo variable, but what if you need to delete the variable in foo? Two steps are required in jquery:
First delete variable:
var index = 1; //需要删除变量的位置foo.splice(index, 1);
Second Delete DOM element:
$ul.find('li:eq(' + index + ')').remove();//实际操作会复杂得多
In angular, you just need to delete the variable foo specified in the controller, which is the first step of jquery above, but it's a little different.
var index = 1;$scope.foo.splice(index, 1);
After that, you don't have to control the DOM element, it automatically deletes the DOM element corresponding to the variable. Similarly, if you want to add a variable, just continue to push (the new variable) in Foo, and jquery is different, it needs not only push, but also append, and even need to know where the push is.
See here, you can probably understand why so many people like Angularjs, because with it you don't have to worry about DOM elements (this is a very painful thing, especially when the data is very much), you just have to define the instructions, and then directly manipulate the variables in the $scope can be, This is a pleasant and convenient thing.
Back to MVVM, what the hell is this? MVVM is actually the model View-view model, which is the binding of the data to the view, the operation data is equal to the Operation view, and the Operation view is equivalent to the operation data, which is the legendary bidirectional binding.
Back to your question, need not learn angularjs, I think is needed. Regardless of the size of the project, ANGUARJS can completely replace jquery, and Angularjs contains jquery (mini version, as little as possible). Learning is not difficult, I took about two weeks to get started, it is recommended to follow the official document case study https://docs.angularjs.org/tutorial, written quite well.
Form validation is more advantageous for angular than jquery, because you don't have to deal with how the DOM handles user input errors, you just have to define the instructions to let angular handle it (it can be handled in conjunction with validator third-party packages, which is simply deadly).
As for animations, angular is simpler than jquery, because it's all written in CSS, a bit different from jquery's Fadein fadeout. Even better, as long as the CSS is defined, all of your Dom's appearance and disappearance are animated, which is much simpler than writing an animation for each Dom in jquery. Even more because CSS animations are GPU-plus (TRANSFORM3D), smoother than jquery is not a little bit.
But angular is not perfect, some shortcomings you must accept, if you project SEO more dependent, with angular a little trouble point, because the view is basically JS to operate, search engine is invisible (solution is also extremely complex), especially with the route, do SEO is more difficult. So most of the time angular used in mobile or app, desktop side less use (not completely useless, mainly jquery now use too many people).
Extended:
React is slightly more complex than angular, involving a virtual DOM knowledge point, it is directly in the JS to write HTML, even instructions do not write, the greatest benefit is the implementation of high efficiency. I was just starting to get into contact, not really used, and had the opportunity to study again.
In addition you speak of Bootstrap, this is UI framework, mainly responsible for the appearance, and jquery angular difference is quite big.
Another, I wrote a cloud album, just started with jquery written, is now slowly migrating to angular, interested can see: http://www.lazycoffee.com
I also just contact Angularjs soon, in order to avoid fraught, please do not reprint
The best place to angular is to write your front-end code the same way you write your backend code.
Template and controller can basically implement the form of classic MVC
Why would you use it?
1-learning threshold low easy to use
2-really makes code better maintained
3-Bidirectional binding is also very convenient.
4-If you use ionic you can't hide angular
5-If you write the WebApp angular on the mobile side can load faster at one time the loading process sub-pages
I also do back-end PHP development, the previous period of time want to do a project, the front-end want to consider using angular, so learning a, experience is
1. Thinking is very cow, the integration of MVC into the front-end development, maintenance is easy
2. But if the project isn't too big, don't think about it.
I am not a professional to do the front-end, may be angular master is not particularly good, but it seems like a long time react seemingly very fire, for the handling of the DOM is a cow fork, if you can pull the body in angular, get that looks good
Personal opinion
Angular is for the "background write-only interface, the front end based on the value returned by the interface to handle the logic" of the app page
You put logic to the backstage, the front desk most of the operations are referred to the background, PHP dynamically generated page This format is not necessary.
双向数据绑定简直相当有用啊,你觉得没有用可能是你还没有遇到相应的情况。比如说你有一js二维数组想要以表格的形式展示在html模型上,而模型上还要给这表格加上增删查改等功能。用angularjs之后你需要做的仅仅只是操作一下js二维数组,不用做任何的dom操作,就能达到目的。不过angularjs却与html和js代码分离的规范相背离确实是个问题。
Agree with the first floor view, learn a set of frameworks, more to learn the ideas. A lot of knowledge is interlinked, learning is a angularjs
knowledge reserve. For example, the university first study c语言
, C#
later study java
will feel much easier