What is ng-app Directive

Question!

What is ng-app directive in brief?

I Have tried this ASP.NET MVC 5 With AngularJS - Part One.



Answers

In order to make your app an Angular app you need to bootstrap AngularJS.

Bootstrapping is the process of intialization i.e. setting up the dependencies.

This is typically done using the ng-app directive, the bootstrapping can also be done from JavaScript using angular.bootstrap

ng-app directive gives a developer the freedom to make the entire application as an Angular app (writing ng-app on the html element) or only a specific part of the application (such as writing ng-app only on a particular div/container)

When we talk about ng-app directive we sure need to discuss about Modules as well. A module is a container for different parts of your application, A module can depend on other modules and you always have a main module as opposed to having a main method like in a C# Console Application.



The ng-app directive tells AngularJS that this is the root element of the AngularJS application.

All AngularJS applications must have a root element.

You can only have one ng-app directive in your HTML document. If more than one ng-app directive appears, the first appearance will be used.

check this for more info http://www.w3schools.com/angular/ng_ng-app.asp



Simple!

We can iterate over the good_synonyms list and check if any of them are present in the input string.

if any(synonym in status for synonym in good_synonyms):
    print('That is good')
else:
    print('That is not so good')

PS: To save memory, you could perhaps store the synonyms only in lower-case, as ['good', 'well'], and when you check if these are in the 'status' variable, you could just apply the .lower() on it, which just converts the entire string into lower-case, as:

good_synonyms = ['good', 'well']
if any(synonym in status.lower() for synonym in good_synonyms):
     print('That is good')

Hope this helps!

Note: holdenweb's answer works too, but applying the split function on status isn't really required as you can check whether a word is present in a string(provided the words in the string are separated by a space) or not using the 'in' keyword as described above.



This video can help you solving your question :)
By: admin