Comments (2)
No, this should clearly be a provider and not a directive since we need to provide an API for the developer to use. If we were to use directives, we would need some sort of provider anyways.
Question and response from another place on the internet:
Generally it's not a good idea to manipulate the DOM from a controller, even via a service. In angular the idea is to set up the scope and let a directive do that work.
|
|
Yes, I know that very well. I got the idea after first seeing the Nprogress project[1] yesterday night and I figured I wanted it for Angular. I was unsure though on how I should implement it. A directive? Well, that would require the developer to do more to be able to change the progress-width/percentage. A provider manipulating a inserted directive? That would require more code.
This morning, I watched Misko talking about best practices regarding AngularJS[2] and he starts talking about that services often shouldn't contain dom manipulation but sometimes it's necessary. In this case, I thought it would be necessary. I think I made a good choice to make it as simple as possible.
[1] http://ricostacruz.com/nprogress/
[2] http://youtu.be/ZhfUv0spHCY?t=26m40s
from ngprogress.
I think this should be a provider plus a directive.
The provider will allow the user to configure the service and interact with the API and the directive will listen to events and showing the progress bar or whatever other behavior it has.
// config block
// interact with ngProgressProvider API
// add an http interceptor or something
// controller
// ngProgress.start
// or if hooked up to the interceptors just do your regular http calls
// html
<ng-progress-bar />
from ngprogress.
Related Issues (20)
- website HOT 4
- Update link reference HOT 1
- Fix naming in bower.json HOT 1
- Broken API? HOT 1
- Typescript definition file HOT 1
- Versions missing from npm HOT 9
- 'main' referenced in package.json doesn't exist. HOT 4
- setParent() not work HOT 4
- Bower Install Warning HOT 2
- ngProgress injected is not the service but the factory HOT 6
- ngProgressFactory function misses it's dependencies HOT 3
- ngProgressFactory injection failed HOT 1
- Documentation issue HOT 1
- progressbar.complete() shouldn't animate unless it has been started
- first param in $timeout&progress speed HOT 1
- TypeError: 'undefined' is not an object (evaluating 'this.parent.appendChild')
- after deploy code in enviroment - ngprogress version not found HOT 1
- NPM Version Request HOT 4
- IE not reflecting DOM updates and progress bar is delayed until the page is nearly done loading HOT 1
- Request for new maintainer HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngprogress.