If in url parameter id is available then i want to call function.
.controller('repeatCtrl', function($scope,$state,$stateParams) {
if($stateParams.id != ""){
//Here i want to call itemDetails function
$scope.itemDetails(id);
};
$scope.itemDetails = function(id) {
// function body here!!
alert(id);
};
})
You issue is you are calling a function before making declaration of it.
.controller('repeatCtrl', function($scope,$state,$stateParams) {
$scope.itemDetails = function(id) {
// function body here!!
alert(id);
};
if($stateParams.id && $stateParams.id != ""){
//Here i want to call itemDetails function
$scope.itemDetails(id);
};
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With