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 7 years ago.
Improve this question
why in AngularJs name conventions, the name of a controller should begin with uppercase letter while others seem to begin with lowercase letter?
It's recommended to name classes with uppercase first letter to distinguish them from simple functions. Since Angular controllers are technically constructor functions which construct new controller instance objects - for consistency it is better to reflect this fact in the name too.
On the other hand, injectable services are not constructors, they are already objects (created behind the scene), so there is no need to name them with uppercase - they are not constructors you are (or Angular) going to use to create new object instances with new keyword.
But of course, this is just a convention, not very strict. Just a nice consistency.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is there a way to define multiple options (to serve as an internal overview / guide) when using PropTypes, as a companion for defaultProps?
I usually just add comments to serve as an overview of the possible options, but is there a better way?
E.g. when I have a button that can take different size (props) arguments such as standard, large, subtle, fitToContent, ...
As a sidenote / side question — I want / need to learn TypeScript, is this something that can be done with TS?
In TypeScript there is something called literal types it's mean that it's will strict you to output you want like the example #konekoy show in the comment
size: "standard" | "large" | " subtle" | etc.
I recommend you start learning TypeScript it's not that hard
and another bonus with TypeScript the IDE works with it perfectly and can make much better IntelliSense.
there will be a little difference between React with js and ts but it's really minor
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 6 years ago.
Improve this question
I have one component that takes quite a bit of data. I have an option to either create 12 props to send down to the child component OR create an object with 12 keys and send the object down by itself.
I honestly see no difference trying one or the other, so I'm trying to get some input as to which setup is better for performance.
Personally, I wouldn't worry about the performance aspect of it until it was obviously an issue. Pre-optimisation can be a bit like falling down the rabbit hole.
Without knowing more about the actual object, I would say that 1 big object (which has 12 keys) would be much to worry about.
Instead, I would pass the object down as one prop and then use destructuring as necessary to any further children.
i.e:
<ChildComponent largeObject={someObject} />
and in ChildComponent:
const { oneKey, twoKey, threeKey } = this.props.largeObject;
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 7 years ago.
Improve this question
I want to know which algorithm is used by the following Applications or WebSite for String Pattern Matching, I have already search by title but nothing found, i want to learn and understand the real time implementation of String Pattern Matching algorithm used by various Applications.
1.Notepad
2.Adobe Reader
3.Web Browsers
4.URL locator
5.StackOverFlow WebSite
Thanks in advance......
For instance a single string matching is the z-algorithm. It's the fastest matcher.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How do i edit an XML nodes property?
I have tried using xmlNewProp, however, that does not overwrite the property. It just adds a new one.
So I was wondering if there is a way to either remove that property, or edit the propery.
Edit:
I understand that some people did not quite get what I was trying to do. Well, the thing was that I needed a way in C using libxml2 to update a nodes properties. I tried using xmlNewProp, however that did not work.
Someone suggested xmlSetProp, and that worked fine. My problem were that the documentation for lxml were huge, and it was difficult to locate the needed functions.
Based on libxml documentation, you can use xmlSetProp to set an attribute from a node.
http://xmlsoft.org/html/libxml-tree.html#xmlSetProp
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
this is probably a stupid question but here it goes anyway. I know that services are like singleton that's good for storing shared data. However I've been struggling with some concepts - Is it true that when using built-in directives like ng-repeat, do we always have to write "middle-man" methods to access/manipulate the shared objects in services? E.g
we have
appModule.service('fruits', function(){
this.items = ["apples", "bananas"];
});
To use ng-repeat to access these items, we must first need to write controller method like
appModule.controller("fruitsController", function($scope, fruits){
$scope.getFruits = function(){ return fruits.items;}
});
How about using custom directives then? Given that the service can also be injected into a directive, it will have direct access to the service. Is there any pros and cons of either methods?
So I think you're asking "Why not use custom directives for everything instead of controllers?"...
Well, basically because that would be harder to test. It's sort of like asking "Why separate code at all?".
The purpose of a directive is to provide two way access between your model and your view (the DOM) and handle setting up those interactions.
The purpose of a controller is to encapsulate "business logic" for the app.
Can you mix them both into a directive? Yes. Should you? Probably not.