carelesslyChoosy carelesslyChoosy - 4 months ago 8
Javascript Question

How to use Functional $scope methods in HTML templates without using ng-click?

I am learning angular for my next project, I am confused how to use a $scope variable (call the function) in my template file, all the example I could find use it with ng-click, or more general how to access business logic of the controller in templates views? for example I have this function

$scope.rows = function(){
var rowNumber;
rowNumber = Math.floor($scope.itemNumber / 6);

var rows = [];
for(var i = 0; i < rowNumber; i++){
rows.push('row'+ i);

return rows;

I want to access this rows array which is getting dynamically generated in ng-repeat?


its easy, just use

<div ng-repeat="row in rows()">
   <span>{{ row }} </span>

here is more information about ng-repeat