在输入上设置文本时,角度ng模型不会更新

时间:2015-09-13 22:58:31

标签: javascript angularjs angular-ngmodel angular-controller

我在角度方面遇到了一些麻烦,希望你能伸出援助之手。

我有这个HTML代码:

</head>
  <body ng-app="starter" ng-controller="editarCtrl">
        <ion-pane>
            <ion-header-bar class="bar-stable">
                <center>
                    <h1 class="title">Agregar Clientes</h1>
                </center>
            </ion-header-bar>

            <ion-content  ng-init="init()">

                <center>
            <img src="\img\ds-firebird-logo-500.png" width="30%">
          </center>
                <center>
                    <button class="button button-possitive" ng-click="addImage()">Editar Foto</button>
                </center>       
                <div class="list">
                    <label class="item item-input item-stacked-label">
                        <span class="input-label" >Nombre</span>
                        <input type="text" placeholder="Escriba su nombre" ng-model="dato_Nombre" >
                    </label>
                    <label class="item item-input item-stacked-label">
                        <span class="input-label">Apellido Paterno</span>
                        <input type="text" placeholder="Escriba su apellido paterno" ng-model="dato_ApPat">
                    </label>
                    <label class="item item-input item-stacked-label">
                        <span class="input-label">Apellido Materno</span>
                        <input type="text" placeholder="Escriba su apellido materno" ng-model="dato_ApMat">
                    </label>
                    <label class="item item-input item-stacked-label">
                        <span class="input-label">Dirección</span>
                        <input type="text" placeholder="Escriba su dirección" ng-model="dato_Direccion">
                    </label>
                <label class="item item-input item-stacked-label">
                  <span class="input-label">Teléfono</span>
                  <input type="text" placeholder="Escriba su teléfono" ng-model="dato_Tel">
                </label>
                    <label class="item item-input item-stacked-label">
                        <span class="input-label">Email</span>
                        <input type="text" placeholder="Escriba su correo" ng-model="dato_email">
                    </label> 
                <center>
              <button class="button button-possitive" ng-click="editarCliente()">Actualizar</button>
              <button class="button button-positive" ng-click="eliminarUsuario()">Eliminar</button>
            </center>    
                </div>              
        </ion-content>
    </ion-pane>
  </body>

这是我的ng-Controller的代码,它在正文中启动时被调用: .controller(&#39; editarCtrl&#39;,function($ scope,$ http){

  .controller('editarCtrl', function($scope, $http) {

    $scope.init = function () {
        $scope.idUsuario=localStorage.getItem("idUsuario");
        $scope.dato_Nombre=localStorage.getItem("dato_Nombre");
        $scope.dato_ApPat=localStorage.getItem("dato_ApPat");
        $scope.dato_ApMat=localStorage.getItem("dato_ApMat");
        $scope.dato_Tel=localStorage.getItem("dato_Tel");
        $scope.dato_Direccion=localStorage.getItem("dato_Direccion");
        $scope.dato_email=localStorage.getItem("dato_email");

        localStorage.clear();




    }

    $scope.editarCliente=function(){
         //debugger;

         $http.get("http://salon.klovuz.com/updateClient.php?"+'idUsuario='+$scope.idUsuario+'&'
            +'dato_Nombre='+$scope.dato_Nombre+'&'
            +'dato_ApPat='+$scope.dato_ApPat+'&'
            +'dato_ApMat='+$scope.dato_ApMat+'&'
            +'dato_Direccion='+$scope.dato_Direccion+'&'
            +'dato_Tel='+$scope.dato_Tel+'&'
            +'dato_email='+$scope.dato_email).success(function(response) {alert("Registro actualizado");
            //debugger;
            location.href = "viewClient.html";});

    }

这个html是通过函数的href打开的。在该函数中,我设置了localStorage数据的值,然后在运行ng-init =&#34; init()&#34;功能

我的问题是,如果我然后修改输入文本并调用我的ng-click =&#34; editarCliente()&#34;函数,我没有得到输入值,相反,我得到ng-model名称(例如:在我的调试器中,dato_Nombre的值=&#34; dato_Nombre&#34;)

我知道这可能不是调用php函数的最好方法,我只是刚接触到角色,我试图弄清楚它是如何工作的。

0 个答案:

没有答案