Can not get value of textbox

Below is my code. In that when I click on fnAddCategory() , It does not give me any value.

> > > >
<ion-content class="padding">
    <form name="category" novalidate>
        <div class="list">
            <label class="item item-input item-floating-label">
                <span class="input-label">Category Name</span>
                <input type="text" placeholder="category Name" name="name" ng-model="categoryName" required>
            </label>
            <label class="item item-input item-stacked-label">
                <span class="input-label">Category Image</span>
                <br>
                <input type="file" name="categoryImg" ng-model="categoryImg">
            </label>


            <span style="color:red" ng-show="category.name.$dirty && category.name.$invalid">
                <span ng-show="category.name.$error.required">Category name is required.</span>
            </span>  

        </div>
    </form>
</ion-content>

And below is my controller code:

.controller(‘addCategoryController’, function ($scope, $location, $http, $stateParams) {
$scope.fnAddCategory = function (categoryName) {
alert(categoryName);
};

    });

Plese help me with this code.

You need to specify a parameter when you call the function. It will need to be something that is available on scope if you’re calling it directly from a button on view. So your button would be

<button class="button button-icon button-clear ion-android-checkmark-circle" type="submit" ng-click="fnAddCategory(categoryName)">

Alternatively, you could leave the button as-is and change your function to grab the value directly from the scope:

$scope.fnAddCategory = function () {
    alert($scope.categoryName);
};

It does not work. Alert is popup with > undefined

Which method did you try? Adding the parameter to the function call or grabbing the value from scope in the function?

Adding parameter to function call.

Can you make a codepen or plunker?

sorry I could not make a codepen or plunker.