angular JS 的可编辑文本就像普通的 link

Editable-Text with angular JS acts like a normal link

你能帮我看看这里做错了什么吗?

我在我的一种表单中使用 xeditable 和 angular 实现了一个带有 angular js 的可编辑标签,但奇怪的是可编辑标签的行为就像一个普通的 link,我遵循了这个文档

https://vitalets.github.io/angular-xeditable/

这是我的相关 html 代码

        <a href="#"  editable-text="user.name">{{ user.name || "empty" }}</a>
    

我正在插入 angular js 控制器和所有东西,我没有收到任何错误,只是它的行为就像一个普通的 link。

编辑我的 app.js 看起来像

'use strict';

var App = angular.module('myApp', [
                               'ngResource',
                               'ngRoute',
                               'ngFileUpload',
                               'angularBootstrapNavTree',
                               'ngAnimate',
                               'angularUtils.directives.dirPagination',
                               "checklist-model",
                               'xeditable'


                             ]);



 //comment
App.config(['$routeProvider','paginationTemplateProvider', function($routeProvider,paginationTemplateProvider) {
 ......

}]);

App.run(['$rootScope','$location','$routeParams','$http','Attribut','Categorie','SsCategorieofcategorie','Produit','ConfigCategorie','editableOptions', function($rootScope, $location, $routeParams, $http, Attribut, Categorie,SsCategorieofcategorie,Produit,ConfigCategorie,editableOptions) {
   editableOptions.theme = 'bs3';
........

    }]);

还有我的控制器:

'var strict';

App.controller('GenerationContenuController',['$scope', '$http','$interval','GenerationContenu','InputText','$timeout',  function($scope, $http,$interval,GenerationContenu,InputText ,$timeout){

    var self=this;
    
        $scope.user = {
          name: 'awesome user'
        };



...



}]);

最后 html

<form id="msform"  ng-controller="GenerationContenuController as ctrl"  editable-form>
  <!-- progressbar -->
  <ul id="progressbar">
    <li class="active">Choix du contenu</li>
    <li>Validation du vocabulaire</li>
    <li>Validation du contenu </li>
  </ul>
  <!-- fieldsets -->
  <fieldset>
    <h2 class="fs-title">Choix du contenu</h2>
        <a href="#"  editable-text="user.name">{{ user.name || "empty" }}</a>
    <div class="form-group">
      <select class="form-control" id="inputText" ng-model="typeInputText" ng-change="ctrl.update()" required>
                <option value="MOT CLE">Mots cles</option>
                <option value="PHRASE">Phrases bateau</option>
                <option value="AVIS">Faux avis</option>
                <option value="CONSEIL">Conseils pour parents</option>
           </select>
           </div>
           <div class="form-group">
           <select class="form-control"  ng-model="selectedInputText" required>
                <option ng-repeat="inputText in inputTexts" value="{{inputText.text}}">{{inputText.text}}</option>
           </select>
           </div>
    <input type="button" name="next" class="next action-button" ng-click="ctrl.genererVocabulaire()" value="Next" />
  </fieldset>

    <fieldSet>
    ....
  </fieldSet>
     <fieldSet>
    ....
   </fieldSet>
</form>

  </div>

我尝试同时设置最大值和保持特定值

你的问题在这里:<form id="msform" ng-controller="GenerationContenuController as ctrl" editable-form>。换句话说,你已经使用了 controller as syntax.Either 删除它或使用最新的 Angular 版本和 it.Hope 这个对你有帮助。

这是没有 controller as 语法的 Fiddle。

Fiddle

这是 Fiddle 的最新 Angular 版本和 controller as 语法:

Fiddle

更新:

如果您需要在表单中使用它,则必须采用不同的方式。

<span editable-text="user.name" e-name="name" onbeforesave="checkName($data)" e-
required>{{ user.name || 'empty' }}</span>

工作Fiddle