<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>
该页面使用angularjs和ionic制成。 我是棱角和离子的新手。 需要在名字之前或名字旁边上传图片。 可以使用该离子图标“”上传图像。 使用了ng-upload,但无法正确理解。
该怎么做?
答案 0 :(得分:1)
您是否安装了Angular File Upload? 以下是使用Angular File Upload的步骤: 在我们的代码中使用它之前,我们需要安装Angular File Upload。
npm install angular-file-upload
安装angular-file-upload
后,我们需要将其作为依赖项添加到我们的angular模块中。要注入依赖项,请运行以下命令:
var app = angular.module('my-app',[ 'angularFileUpload' ]);
现在您可以在代码中的任何地方使用它。
例如: 在HTML中:
<input type="file" nv-file-select uploader="uploader"/><br/>
在uguglar模块中:
.module('app', ['angularFileUpload'])
.controller('AppController', function($scope, FileUploader) {
$scope.uploader = new FileUploader();
});
您可以在此link上找到简单的示例。 希望对您有所帮助。