what is the difference between ng:click and ng-click? [closed] - angularjs

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I can't find any documentation on ng:click. My todo list application does not work unless I use ng:click as opposed to ng-click, yet I can't find any documentation on it. Is it the same as ng-click?

From the docs here: http://docs.angularjs.org/guide/directive
The normalization process is as follows:
Strip x- and data- from the front of the element/attributes. Convert
the :, -, or _-delimited name to camelCase.
So, angular interprets all of these as ngClick and then runs the directive named ngClick.
<button ng:click="myFunc()">ng:click</button>
<button ng-click="myFunc()">ng-click</button>
<button ng_click="myFunc()">ng_click</button>
See this live demo (click).
This being, your issue must be with your usage, which is not included. As this post is asking "What is the difference" and you have been answered that there is none, you might want to make a new post concerning the issue with your code and include your code.
Update based on your comment:
There are so many problem with your code that it would be unreasonable to go into depth about all of them. I'll give you some starting points for study.
First, here's a live demo of your code as it ought to look: http://jsbin.com/arAkuZo/6/edit
The "br" tag is deprecated and should no longer be used. Use css for that.
Your angular version is far out of date.
Don't use the global syntax for angular. Make a module and add your controller, etc to it.
There are several directives like `ngModel` that you seem to be unfamiliar with.
camelCase is the accepted standard for variable naming and Angular emphasizes it, so make it a note to use camelCase always. (at least almost always).

Yes, they're the same thing. Read http://docs.angularjs.org/guide/directive and http://docs.angularjs.org/guide/ie.

Related

Using AI generators to ask questions to provoke thinking instead of giving answers? [closed]

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 1 year ago.
Improve this question
I have a use case that I want to use to help independent creators talk about their interests on Twitter using their experiences.
It goes like this:
You have an interest you want to talk about Entrepreneurship
You have an experience like Pain
Is there a way for an AI (like GPT) to generate prompts that uses these two words to create a list of open-ended questions that provoke thoughts such as these:
If entrepreneurship wasn't painful, what would it look like?
What do you know about entrepreneurship that is painful that starters should know?
How can you lower the barrier to entrepreneurship so that it's a less painful opportunity for a person to take?
If so, how will it work, and what do I need to do?
I've explored Open AI's documentation on GPT-3, I'm unclear if it solves this problem of generating prompts.
Thanks!
You should provide some samples so that the GPT-3 can see the pattern and produce a sensible response from your prompt.
For example, see the following screenshot from your case. Note that the bold text is my prompt. The regular text is the response from GPT-3. In that example, I was "priming" the GPT-3 with relevant pattern: First line, the general description, then the Topics, followed by Questions. This should be enough for booting up your ideas and customizations.

How to handle dynamically changing ID's on refresh? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
How to handle dynamically changing ID's on refresh?
It's very common question but i would like to answer this question.
If id's are dynamic the you can go with any other locator techniques which ever is suitable in case of your app.
e.g. Name , className.
Mostly use of advance css or Xpath should work in your case. but you need to find unique set of properties / attribute values to locate.
Keep this in mind - just ignore on the part which is changing...focus on the part which is not changing and try to use that in any locator you choose.

Angular JS : When should you use an attribute versus an element? [closed]

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 5 years ago.
Improve this question
As an angularjs developer i want to know when i should use attribute versus an element
AS per my understanding and development knowledge Use an element when you are creating a component that is in control of the template. Use an attribute when you are decorating an existing element with new functionality.
But i am not sure ... please suggest
Angular directive documentation
Original answer by ckruszynsky:
The angular guidance says that you should use the "element"
restriction whenever the directive has full control over it's template
meaning it has a template that it is rendering out, etc.
For attributes, they suggest to use these only when you are adding
"behavior" to an existing element or decorating an existing element.
For example, think of the ng-click directive, this is used a attribute
not as a element because the click directive is just adding the click
behavior to some element.
Another example would be the ng-repeat directive, it is also used as
an attribute not as a element because it is going to repeat the
element in which it is being used in.
Now, this guidance is from the angular documentation; however, I don't
know necessarily that element vs. attribute is going to give you a
"better" approach it's more of a convention.
Now if you have to support older browsers, then you may want to
consider using either the comment or class directives.
My personal preference is to just use the attribute restriction;
mainly because people that are new to angular get overwhelmed at first
when they see the restrict and it's variations of the options that can
be used.
This question is quite opinion based, personnaly i use only attributes but i'm probably not the one to follow
However i can address some points following how HTML is designed :
element fits for a component (like an input, table).
attributes fits for options that influence the behaviour of your component (like type="text"). But they can be used as components too, as long you don't use two of them in the same element.

What is the point of encapsulation? [closed]

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 just don't see the point of encapsulation, I see that in some cases you can modify a getter/setter to modify the behavior of something or keep track of state, but whenever I am creating a non-conventional getter/setter, I use a word like "modify," or "obtain," so what is the point of wasting hours writing repetitive methods that are practically pointless and inefficient?
I just don't get it, when I was a wee young programmer, I was told by some guy in an IRC, that not having it was the cause for a bug in my program, but I have known for years now that is not the case, I've just been doing it anyway, so what is then point?
If I need to refactor later there are ways around it weird ones but they are ways at least in languages with overloaded operators, and API's don't always have to be backwards compatible so I don't see the point.
Can anyone enlighten me to the necessity of encapsulation?
In many cases you are right - small programs doesn't need encapsulation probably.
Some MS infrastructures (C#/WPF I think in several binding scenarios) requires encapsulation (using properties) and will not work without it.
If you do more in get / set than changing the value or returning it - it will make your code nicer and more robust (do checks, or other staff in the setter for example).
No one forces you to use it anyway...

Best way to implement on-button feedback [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'd like the buttons in my app to give feedback, as for example demonstrated here.
I'm wondering how I should structure my code. I want to be able to change the classes, the text and maybe disable them upon click. I guess a directive is the right fit, but the exact changes that will happen depend upon the button, and putting content or class names inside a controller or directive doesn't seem very right.
Right now i have a very generic directive that takes all options through additional attributes, but I wonder if someone can see a better way of doing it?
Always start with a very simple directive and extend with CSS classes. If you want to do a particular work well anything you can use a function of the controller. I think you made ​​the right choice. Think to look angular UI for best practice : http://angular-ui.github.io
You can add event on each action:
// Create a new instance of ladda for the specified button
var l = Ladda.create( document.querySelector( '.my-button' ) );
// Start loading
l.start();
// Will display a progress bar for 50% of the button width
l.setProgress( 0.5 );
// Stop loading
l.stop();
// Toggle between loading/not loading states
l.toggle();
// Check the current state
l.isLoading();

Resources