AngularJS: Using ng-repeat

AngularJS is the Javascript MVC framework developed by Google. In this post we will build a simple application using AngularJS. If you aren't familiar with it, you might want to read my introduction to AngularJS first. This post will introduce the concept of controllers and the app will display a simple list of items (persons) to the view.

In this application I will be using AngularJS 1.0.6 which is the latest stable version as of this writing. For the CSS, I am using Twitter bootstrap.

Setting up the Files

First off, here's the barebones html file as well as what it looks like when run:

Resetting the Primary Key of a Table

This quick tip will show how to reset the primary key values for a table in SQL Server:

DBCC CHECKIDENT ([Table], RESEED, [NewCurrentValue])

Where [Table] is the table name and [NewCurrentValue] is the new current value of the id. This would ideally be set to 0, so that the next value (when a row is inserted) will be 1.

Simple Ways to Prevent SQL Injection Attacks

Recently I've been working on a library that would allow direct CRUD operations of any object to the database. The library would detect the types and values of the properties of the classes involved then create Insert, Update, GetAll, and GetById procedures depending on what they find.

It was working great and I was happy with the result. However when I showed it to a friend he pointed out that there might be security concern for building such queries. I researched about it a little and I found he was correct: my code was vulnerable to SQL injection attacks.

Introduction to AngularJS

If you've been reading about javascript frameworks then you're probably seen AngularJS. AngularJS is a javascript framework developed by Google. It supports a MVC pattern and handles two-way data binding between the model and the view. Aside from two-way data binding, it also has support for declaring new html syntax, validation, routing, and more. In this post we will talk about the data binding capability.

Setting Up the Site

First off, we need to have a reference to the AngularJS file, which you can download from here. In this example I downloaded the Uncompressed build of the Stable branch (1.0.6).