Giter Club home page Giter Club logo

Comments (2)

victorb avatar victorb commented on May 28, 2024

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.

ostera avatar ostera commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.