You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
1A perfect answer. I wonder if any angular googlers can offer and better solution? Certainly for services such as logging and analytics this is very important.sidonaldson– sidonaldson2013-09-11 08:55:10 +00:00Commented Sep 11, 2013 at 8:55
-
1Is there a way to amend this so that the binding is added inside the service definition?sidonaldson– sidonaldson2013-09-11 09:01:01 +00:00Commented Sep 11, 2013 at 9:01
-
5@sidonaldson This is generally considered an anti-pattern in the angular world. Because it makes for a less testable environment (due to the assumption that the service is always available on a scope). That's why you don't see many posts on this topic.Christopher WJ Rueber– Christopher WJ Rueber2013-11-19 17:44:21 +00:00Commented Nov 19, 2013 at 17:44
-
7@rob - According to best practices, the factory should be injected in to the controllers that need to use it, rather than on the root scope. As asked, question number one actually is the antipattern. If you need the factory 100 times, you inject it 100 times. It's barely any extra code when minified, and makes it very clear where the factory is used, and it makes it easier (and more obvious) to test those controllers with mocks, by having the required factories all listed in the function signature.Christopher WJ Rueber– Christopher WJ Rueber2013-11-25 20:06:03 +00:00Commented Nov 25, 2013 at 20:06
-
5@chris - I agree and have since come to the same conclusion after using Angular for some time. If you articulate this in an answer I will select it at the best answer (if that's possible, haven't overridden an answer selection before). Otherwise I will probably just edit this post when I find the time.Robert Christian– Robert Christian2013-11-28 01:57:12 +00:00Commented Nov 28, 2013 at 1:57
|
Show 3 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. python-3.x), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-js