Angular - 当表单文本输入不为空时隐藏Div

时间:2016-01-18 00:40:19

标签: angularjs

基本上我想在有人为一个盒子添加文字时隐藏一次潜水。

我有一个表单,有人可以上传图片或添加图片链接。当用户添加图像链接时,我想隐藏上传按钮

现在我知道当他们选择要上传文本框的图片时会被隐藏但我不能反过来工作。

我想隐藏div"手动上传"当用户将文本添加到数据-ng-model =" dealsCTRL.urlimage"

<div class="manual-upload">

                              <div class="text-center form-group controls" ng-hide="uploaderProduct.queue.length">
                            <span class="btn btn-default btn-file">
                                Select Image <input type="file" nv-file-select uploader="uploaderProduct">

                            </span>
                              </div>

                              <div class="sub-label"> Upload an image of product.</div></br>

                              <div class="text-center form-group" ng-show="uploaderProduct.queue.length">
                                <button class="btn btn-primary" ng-click="uploadProductPicture();">Upload</button>
                                <button class="btn btn-default" ng-click="cancelProductUpload();">Delete</button>
                              </div>



                              <div ng-show="success" class="text-center text-success">
                                <strong>Upload Successful</strong>
                              </div>
                              <div ng-show="error" class="text-center text-danger">
                                <strong ng-bind="error"></strong>
                              </div>

                              </div>

                              <div class="add-image-link">

                              <label class="control-label" for="urlimage" ng-hide="uploaderProduct.queue.length">IMAGE URL</label>

                              <div class="controls" ng-hide="uploaderProduct.queue.length">
                                <input type="url" data-ng-model="dealsCTRL.urlimage" id="urlimage" class="form-control"
                                       placeholder="Image URL" ng-change="blankPhoto()" required>

                                <div class="sub-label">Manually enter an image URL.</div>

                              </div>

                              </div>

2 个答案:

答案 0 :(得分:0)

请尝试以下方法:

<div class="manual-upload" ng-show="dealsCTRL.urlimage.length === 0">

答案 1 :(得分:0)

您希望在开始输入时隐藏元素

div class="manual-upload" ng-hide="dealsCTRL.urlimage.length > 0"