1

enter image description here

            <label class="item item-input item-stacked-label" ng-class="{ 'has-error-lr' : userForm.firstName.$invalid, 'valid-lr' : userForm.firstName.$valid}">
                <span class="input-label">First name</span>
                <input type="text" name="firstName" ng-model="user.firstName" placeholder="Type first name" ng-pattern="/^[a-zA-Z\.'\s]*$/" required>

                <div class="form-error wrap-text" ng-show="userForm.firstName.$error && userForm.firstName.$invalid && userForm.$submitted">

                    Please enter valid a name, special characters or numbers are not allowed.
                </div>
            </label>

            <label class="item item-input item-stacked-label" ng-class="{ 'has-error-lr' : userForm.lastName.$invalid, 'valid-lr' : userForm.lastName.$valid}">
                <span class="input-label">Last name</span>
                <input type="text" name="lastName" ng-model="user.lastName" placeholder="Type last name" ng-pattern="/^[a-zA-Z\.'\s]*$/">
                <div class="form-error wrap-text" ng-show="userForm.lastName.$error && userForm.lastName.$invalid && userForm.$submitted">
                    Please enter valid a name, special characters or numbers are not allowed.
                </div>
            </label>

            <label class="item item-input item-stacked-label" ng-class="{ 'has-error-lr' : userForm.userEmail.$invalid, 'valid-lr' : userForm.userEmail.$valid}" ng-if="!isEditing">
                <span class="input-label">Email</span>
                <input type="email" name ="userEmail" ng-disabled="isEditing" ng-model="user.userEmail" placeholder="Type email">
                <div class="form-errors"  ng-messages="userForm.userEmail.$error" ng-if="userForm.userEmail.$invalid && userForm.$submitted" ng-messages-include="templates/form-errors.html"> </div>
            </label>

            <label class="item item-input item-stacked-label" ng-class="{ 'has-error-lr' : userForm.contact.$invalid , 'valid-lr' : userForm.contact.$valid}">
                <span class="input-label">Contact no</span>
                <input type="tel" name="contact" ng-model="user.contact" placeholder="Type contact number" pattern="^\d{10}$" maxlength="10" required>
                <div class="form-errors"  ng-messages="userForm.contact.$error" ng-if="userForm.contact.$invalid && userForm.$submitted" ng-messages-include="templates/form-errors.html"> </div>
            </label>

            <label class="item item-select item-input" ng-if="!isEditingSelfAccount" ng-class="{ 'has-error-lr' : userForm.role.$invalid , 'valid-lr' : userForm.role.$valid}">
                <span class="input-label">Select role</span>
                <div data-tap-disabled="true">
                    <select ng-model="user.role" ng-change="setClassesArrayToUserObject()" name="role" required>
                        <option value="admin" ng-if="userRoleType.isAdmin">Admin</option>
                        <option value="teacher" ng-if="userRoleType.isAdmin">Teacher</option>
                        <option value="student" ng-if="userRoleType.isAdmin || userRoleType.isTeacher">Student</option>
                    </select>
                </div>
                <div class="form-errors"  ng-messages="userForm.role.$error" ng-if="userForm.role.$invalid && userForm.$submitted" ng-messages-include="templates/form-errors.html"> </div>
            </label>

the page is made using angularjs and ionic. I am new to angular and ionic. Need to upload an image before first name or beside it. This ionic icon can be used "" to upload an image. Used ng-upload, but was not able to understand it properly.

How to do that?

1
  • you can use image picker for pick images and then upload it by converting base64 string Commented Dec 19, 2018 at 9:33

1 Answer 1

1

Did you install Angular File Upload? Here are the steps to use Angular File Upload: We need to install Angular File Upload before using it in our code.

  1. Open Command Prompt
  2. Go to your project root directory
  3. run command npm install angular-file-upload After installing angular-file-upload we need to add it in our angular module as dependency.
  4. To inject dependency run below command:

    var app = angular.module('my-app', [ 'angularFileUpload' ]);

Now you can use it anywhere in code.

For example: In Html:

<input type="file" nv-file-select uploader="uploader"/><br/>

In anuglar Module:

.module('app', ['angularFileUpload'])
.controller('AppController', function($scope, FileUploader) {
    $scope.uploader = new FileUploader();
});

You can find simple example on this link. I hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.