AngularJS with TextArea and Scroll To

posted in: Uncategorized | 0

This is part four of my look into AngularJS.
  1. AngularJS Intro and Setup
  2. AngularJS and Modernizr
  3. AngularJS and jQueryUI DatePicker
  4. AngularJS with TextArea and Scroll To
  5. AngularJS and Javascript Tips
  6. Coming soon…

 

Using textarea For Multiline Input

In AngularJS this is how you would use textarea in HTML.

For more information on attributes that are available, read the textarea article on the Mozilla Developer Network.

To display the text from the textarea that has multiple lines in the view, you can do something like the following:

For more about this see the discussion: angularjs newline filter with no other html.

 

Scroll To Element

In AngularJS, when trying to do <a href="#">back to top</a>, it does not work properly. What happens is the whole website is reloaded instead of just going to the top of the page. This is where scroll to a particular element using id="name" attribute in the HTML page comes in.1

First, in the directives.js add the following code that would animate the scrolling to a particular element in the webpage:

What does restrict: 'A' mean? It means it only matches the attribute name.

In the next line, the scope: {...} means:
=&0=&

AngularJS and jQueryUI DatePicker

posted in: Uncategorized | 0

This is part three of my look into AngularJS.
  1. AngularJS Intro and Setup
  2. AngularJS and Modernizr
  3. AngularJS and jQueryUI DatePicker
  4. AngularJS with TextArea and Scroll To
  5. AngularJS and Javascript Tips
  6. Coming soon…

 
Instead of using HTML5 date input type which is not supported by Internet Explorer and Firefox, I decided to use the AngularJS version of jQueryUI DatePicker called angular-ui-date.1, 2

 

Adding angular-ui-date

To begin, edit bower.json and add the following line:

Then run bower install to install angular-ui-date.

Next edit js/app.js to include the following before ngRoute:

In the index.html add the following inside the <head> section:

While still editing the index.html add the following to the script section: jQuery before angular.js. Otherwise, it would use a lite version of jQuery called jQLite.3

 

Using angular-ui-date

Inside the HTML template:

In the controller.js:

The options for angular-ui-date are the same as jQueryUI DatePicker. For further information see jQueryUI Datepicker for AngularJS.

 


READ MORE

AngularJS Intro and Setup

posted in: Uncategorized | 0

This is part one of my look into AngularJS.
  1. AngularJS Intro and Setup
  2. AngularJS and Modernizr
  3. AngularJS and jQueryUI DatePicker
  4. AngularJS with TextArea and Scroll To
  5. AngularJS and Javascript Tips
  6. Coming soon…

 

Introduction

AngularJS is a open source, cross platform, javascript framework. It is used to develop single page applications (SPA). A SPA is when resources are loaded and added dynamically as needed and the page is not reloaded. The first version (1.0) of AngularJS was released in 2012 and was in development since 2009. It follows the model view controller (MVC) idea.1

The main point with AngularJS is you have directives: ng-app, ng-model (binding between the view, html, and the scope, i.e. controller), etc. and expressions: {{ phone.name }} will be replaced by the value of the expression.

The current version of AngularJS, as of writing, is 1.2.24 static-levitation (2014-09-09) which can be found here: https://github.com/angular/angular.js.

 

Setup

To get an idea of AngularJS try out the tutorial found https://docs.angularjs.org/tutorial. Another resource is


READ MORE