James Lemon
James Lemon

Reputation: 426

ng-repeat not showing anything

I expect to push new row for user to put in extra info but I'm stuck at generate the first row

<div ng-repeat="row in rows">
<input type="text" placeholder="name"><input type="tel" placeholder="tel">
</div>

$scope.rows = {
   '1':1
};

}

http://plnkr.co/edit/qNPYKwdRPNXRrqphEfdz?p=preview

Upvotes: 1

Views: 63

Answers (3)

programmingheadaches
programmingheadaches

Reputation: 143

In your plunker the html has a reference to a controller that doesn't exist.

Replace:

<html ng-app ng-controller="personController">

With:

<html ng-app>

In your controller you put a json object on scope

$scope.rows = {'1':1};

I suggest using a JSON array instead:

$scope.rows = [
{"firstName":"John", "lastName":"Doe"}, 
{"firstName":"Anna", "lastName":"Smith"}, 
{"firstName":"Peter","lastName":"Jones"}]

Regards Ian

Upvotes: 1

ltalhouarne
ltalhouarne

Reputation: 4636

You have ng-controller="personController" but no implementation for that controller.

Upvotes: 0

Michael
Michael

Reputation: 3326

Because you have to remove ng-controller="personController" from the html tag.

AngularJS is searching for that controller, but it doesn't exist, giving an error on the console.

Updated plunker: http://plnkr.co/edit/N14qOlvzPF8eIuPj1I4U?p=preview

Upvotes: 2

Related Questions