AngularJS Bind examples array of objects
by Ben Clayton
HTML
<div ng-app ng-controller="fileController">
<div ng-click="add()" title="click to add file" class="but">+</div>
<div ng-repeat="file in files">
<input ng-model="file.path" class="inp"></input>
<img height="40" width="40" src="{{file.path}}" title="robo1" alt="robo1 Thumbnail" />{{file.path.split('.').pop()}}
</div>
<br/><br/>
<div class="inl" ng-repeat="x in [1,2,3,4,5,6,7,8,9]">
<img height="40" width="40"
src="{{dom}}/dyn/_pictures/robots/_thumb/robo{{x}}.jpg" />
</div>
</div>
CSS
.inp {width:350px;}
.but {font-size:30px;cursor:pointer;background-color:#C0C0C0;border-radius:50%;display:inline-block;line-height:18px;padding:3px;width:22px;height:22px;text-align:center;}
.inl {display:inline-block;}
JavaScript
function fileController($scope) {
$scope.files = [];
$scope.dom = "//flowcms.infxsolutions.com";
$scope.add = function () {
debugger;
$scope.files.push(new fileobj($scope.dom+"/dyn/_pictures/robots/_thumb/robo"+($scope.files.length+1)+".jpg"));
};
}
function fileobj(p){
this.path=p;
}