Angular JS for Beginners: Your Guide to Easily Learn Angular JS In 7 Days by iCode Academy

Angular JS for Beginners: Your Guide to Easily Learn Angular JS In 7 Days by iCode Academy

Author:iCode Academy [Academy, iCode]
Language: eng
Format: azw3
Published: 2017-08-15T04:00:00+00:00


Summary:

AngularJS provides the Events directives ng-click, ng-show, and ng-hide to add custom code that can be used to respond to user- generated events like keyboard entries and clicks.

The ng-click is the most commonly used Events directive. It is used to create codes that will direct the application to perform tasks in response to button clicks.

HTML elements can be shown or hidden to users using the ng-hide or ng-show attributes.

Chapter 12: select boxes

AngularJS allows you to create a dropdown list based on an object or elements of an array.

The ng-repeat directive can be used to repeat the execution of a block of code for each array element. This makes it capable of creating options that can be used in dropdown lists. The ng-repeat directive, however, is currently limited to handling string values.

The AngularJS documentation recommends the use of the ng-options directive for creating dropdown lists. This directive is specifically provided for generating a dropdown list with options. It is used to create a list of items within the <select> element.

While you can use the ng-repeat directive in place of ng-options to achieve the same result in many cases, the use of ng-options offers some advantages:

It allows greater flexibility in terms of determining how the select’s model should be assigned within the comprehension expression.

Because it does not create the options individually, the use of ng-options greatly improves rendering speed.

It helps reduce memory usage because you need not create a new scope with every repeated instance.

Another distinct benefit of using ng-options over the ng-repeat directive is its capability to handle non-string objects for selected values. This allows the value to store more types of information which can make your application more flexible.

To demonstrate how the ng-repeat and ng-options directive work on arrays, you can use the following array data:

$scope.subjects = [

{subject : "Mathematics", session : "PM"},

{subject : "Science", session : "AM"},

{subject : "Geography", session : "AM"}

];



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.