Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm newer to angularjs, it's difficult to understand the custom directive examples and the releated blogs.
why we use it and what is the usage of custom directives.(Using the built in directives is easy to understand and use)
It's possible to write our own custom directives based on our needs ?
what is the need of custom directives in angular js?
Directives could be used to increment the reusability of code.
Directives infact could be used to split the code of a complex app into more simple parts, reusable in others pages or projects.
Directives could be used to save the two way data binding, when AngularJS is used in conjunction with third party plugin.
Generally directives are used for DOM manipulation
Angular’s philosophy is modular development allowing us to write our front-end code with directives
I hope will helps you
Reusablity of code..... You can reuse your code at any Pages and anywhere in your projects.
solve the complex operations in this easily.
Reduce the amount of your code.Call it anywhere.
Handle your Dom easily.
Custom directives gives you the chance to define your own "web components", a very simple example would be a customize menu for your application, using custom directives you could write it once and use it in several applications.
Read more about it and you'll find it very useful (but completely optional as you might have enough with built in ones).
As an example, I find this link quite useful.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I know that for a simple static website, using plain HTML.. is the easiest and quickest way. But, what are some use cases between the two options? Is using a framework mostly the best solution?
You can basically see frameworks as pre-written structures for your App.
In other words, frameworks are meant to help you building applications quicker by addressing common development problems.
So, going back to your question, there are not really times where you would prefer vanilla javascript over frontend frameworks due to the incapacity of scaling well, which could result in inscrutable and unmaintainable spaghetti code.
Other bit you would want to consider about frameworks, is their high performance obtained thanks to their virtual DOM (abstract map of the real DOM), which helps handling events to update parts of the App without the need of re-rendering it.
On the other hand, I would suggest to go with a static website using pure HTML and Vanilla JS, only if learning / instructing someone, or if building something really really simple (but rest assure 99% of your commercial websites may suit better under a framework rather than without).
If you want to read more about it, I would suggest the following articles:
https://stackoverflow.blog/2020/02/03/is-it-time-for-a-front-end-framework/
https://gomakethings.com/why-do-people-choose-frameworks-over-vanilla-js/
https://www.freecodecamp.org/news/do-we-still-need-javascript-frameworks-42576735949b/
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Angular 1 excels in data binding and provided a structued MVC MVW framework.
It fails in providing built-in modularity.
What are the core selling points of Angular 2? Im not looking for opinion, just plain simple bullet point facts and Im only interested in core selling points.
Also what other libraries such as bootstrap / polymer gel well with angular 2?
For me? Just off the top of my head:
Support for Functional Reactive Programming using RxJS Observables.
Built from the ground up with Typescript, meaning Types are a first class construct.
Unidirectional data flow.
Native ES6 Modules, no more endless script tags.
Fully component based.
Better template syntax.
An even better Router.
Much better Dependency Injection.
Support for sped up initial loads thanks to server-side prerendering.
ZoneJS Support, no more digest loop!
Of those my favorite feature is definitely the FRP support. We can drastically enhance performance by using Immutable Objects or Observables for our change detection.
The Formbuilder API as well as the HTTP API is fully compatible with RxJS making it very very powerful.
As for libraries, Angular-Material is obviously a big one. Another favorite of mine is NativeScript, which aims to create fully native mobile applications from your Angular 2 App. I'm sure there'll be tons more once it actually releases.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I was playing with ReactJS for a bit, and given a bit of prior exposure to AngularJS, and the way things are done in the latter, I had a hard time to get used to the syntax and the 'flow' of React.
So I had the above-mentioned question, plus: are there scenarios when ReactJS should be preferred to AngularJS?
Could anyone point out what can be done [easier/better/more efficiently] in React rather than in Angular, and other way around.
It's actually the opposite. Angular has a lot of features, apis, configuration options, etc. React tries to be much simpler and let you choose how your application is structured. Controllers, directives, and templates are reduced to just components. Services are just plain JavaScript, there's nothing React specific about it. Things like $q and $timeout don't exist because there's no digress (use anything you like for those).
You use React in your application, vs making your application in angular.
ReactJS uses the concept of virtual DOM which speeds up the rendering of the app.
Watch Pete Hunt's excellent video on Virtual Dom here:
https://www.youtube.com/watch?v=-DX3vJiqxm4
The syntax might be very unconventional but the same thing can be said about Angular's concept of Directives, services, controllers, etc. It just takes time to get used to, but once you feel comfortable, you'll find that thinking in ReactJS really makes sense.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
AngularJS is famous of the '3d': data binding, dependency injection and directives. As data binding is such a nature of angularJS application, I always assume data-driven is the best approach when making decision on how the app works.
For example, if I want to respond to some property updates, I will $watch on that property and write call back functions for it. And if I can use angularJS properly, there is no $apply required and the two way data binding will automatically do the magic with the great digest cycles.
However, in jQuery or many other JavaScript libraries, event-driven seems to be so common that people always think this is how client side should work. Event-driven approach in angularJS, on the other hand, means I need to $emit or $broadcast events across directives/controllers to throw events here and there. This is somehow different to the data-driven approach.
My idea is event-driven makes the whole application hard to debug, understand and maintain. The only reason I use it is because it's easy to pass data across scopes, when the nested scopes themselves are too complicated to do so.
Any idea on this? When should we stick to data-driven and when should we use event driven? What is the best approach in general?
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm confused between the two choice which one to use BackboneJS/CanJS for my next project. Can anyone suggest which one is better ?
They have many similarities and differences, here are some:
Similarities
They both have models that can be observed, they use similar patterns for setting attributes
CanJS has Controls which in are quite similar to Views in Backbone, you listen to events in similar way in both
They are both small and very flexible
Routing in quite similar in both, Backbone has a special Router object while in CanJS you do the routing inside a Control class, but they are quite similar
I found that many of the patterns of doing things in Backbone are translatable to CanJS
Differences:
Backbone has a huge community, tons of plug-ins for doing about anything
You are likely to find more documentation and help when using Backbone
Backbone doesn't have a prescribed way of doing things e.g. rendering views. So this can be good or bad, depending on how you see it. Many time it leads to many projects doing things totally different when using Backbone.
Backbone doesn't implement view rendering or two way bindings, is up to you to implement that somehow
CanJS has reactive views using EJS or Mustache, so there is a defined way of doing this, it also has two way bindings
CanJS has components
CanJS is quite good at avoiding memory leaks, if you follow certain patterns, for example if you are listening for a window resize event inside a control, when you remove the control from the DOM CanJS will also remove the listeners automatically, in Backbone you have to do more manual work