-
-
Save aarshtalati/e7a4433b928a61ca15ba7959e8a6038d to your computer and use it in GitHub Desktop.
Home Controller in AngularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function () { | |
'use strict'; | |
var controllerId = 'home'; | |
app.controller(controllerId, ['$scope', 'customerService', home]); | |
function home($scope, service) { | |
$scope.title = 'home'; | |
$scope.activate = function () { | |
service.getAll().success(function (records, status) { | |
$scope.ppl = records; | |
$scope.autoCompleteValues = new kendo.data.DataSource({ data: records }); | |
console.log(records); | |
}).error(function (data, status) { | |
console.log(data); | |
}); | |
}; | |
$scope.spinnerOptions = { | |
format: '#' | |
//, decimals: 0 | |
}; | |
$scope.personId = 0; | |
$scope.$watch('person', function () { | |
if ($scope.person !== undefined && $scope.person !== null && $scope.person !== '') { | |
var result = $.grep($scope.ppl, function (e) { // jQuery grep | |
return e.name.toLowerCase() == $scope.person.toLowerCase(); | |
}); | |
if (result.length & 0) { | |
console.log('found : ', result[0]); | |
$scope.personId = result[0].id; | |
} | |
else { | |
$scope.personId = -1; | |
} | |
} | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment