When you do not type anything, do not show "Enter a name"

1

I'm messing with an application made in Ionic. In it, when I search for a photo in Google and select it, the field name is filled with the word that made the search. Now, when I select an image from my phone, the field to put the name is already empty to put any name, but can leave it blank if you want. The problem is when you leave blank and have share, the generated image is named "Enter a name".

The code:

         <div class="col-50 block text-right panel" style="margin-right: 2px;position:relative;" ng-click="showOptions(image1)">
            <div ng-show="!shouldShowImage(image1.src)" style="text-align: center;margin:15px;">
              Selecione a sua foto ou a foto de um amigo!
              <div>
                <a class="button button-icon ion-camera larger" ng-click="takePicture(image1)"></a>
                <a class="button button-icon ion-images larger" ng-click="chooseFromGalery(image1)"></a>
                <a class="button button-icon ion-search larger" ng-click="searchImage(image1)"></a>
              </div>
            </div>
            <!--<ion-content direction="xy" locking="false" scroll="true" ng-show="shouldShowImage(image1.src)" ng-click="showHideCleanButton(image1)">
                <img id="image1" ng-src="{{image1.src}}">
            </ion-content>-->
            <ion-scroll zooming="true" direction="xy" scrollbar-x="false" scrollbar-y="false" min-zoom="1" max-zoom="3" ng-show="shouldShowImage(image1.src)" ng-click="showHideCleanButton(image1)">
              <img id="image1" ng-src="{{image1.src}}" style="height:100vmin;">
            </ion-scroll>
              <div class="imagelabel" ng-show="shouldShowImage(image1.src)">
                  <!--{{image1.textname == null ? "digite um nome..." : image1.textname}}-->
                  <input type="text" placeholder="Digite um nome..." ng-model="image1.textname" style="text-align: center;">
              </div>
            <div style="position: absolute;top: 0px;left: 0px;" ng-show="showClearButton(image1)">
              <button ng-click="clean(image1)" class="button button-energized"><i class="icon ion-close-circled"></i></button>
            </div>
              <!--<div id='parent' style="position:fixed;bottom:0px;">
                  <div id='child' style="width:100px; margin:0px auto;">
                      centered div
                  </div>
              </div>-->
          </div>

Does anyone know how to solve this problem?

    
asked by anonymous 16.12.2015 / 18:25

2 answers

2
<input type="text" id="txName" placeholder="Digite o nome" ng-model="image1.textname" style="text-align: center;">

When you shoot the function to save the photo, at the beginning of it you do

$('#txName').prop('placeholder','');

or

$('#txName').attr('placeholder','');

To remove it only at the correct time and not influence the final result that is the image.

    
16.12.2015 / 18:30
0

Friend,   Ionic (better, AngularJs!) Appreciates for not changing the DOM via controller.   My suggestion is that you control the placeholders or file names via scope variables.   Here is an example of a select that, when changed, changes the placeholder text of a textarea:

Template.html:

<select ng-model="tipoUsuario" ng-change="userChanged()" >
   <!-- options... -->
</select>
<textarea placeholder="{{dicaDeTexto}}"></textarea>

Controller.js:

$scope.userChanged = function( ) {
    $scope.dicaDeTexto = $scope.tipoUsuario.dica;
};
    
18.01.2016 / 17:01