【问题标题】:Angularjs ng-model become one way inside the kendo ui tabstripAngularjs ng-model 成为 kendo ui tabstrip 中的一种方式
【发布时间】:2014-01-01 20:08:01
【问题描述】:

我在一个小项目中使用 angularjs+kendoui。 (我正在学习angularjs)

但是我发现 ng-model 只能以一种方式工作(它可以从控制器/模型填充到 UI)但是当我更改 UI 时,它无法填充模型。

下面是一个简单的例子。

标签内有一个文本框。当我更新文本时,模型没有更新。 我在选项卡外还有另一个文本框。当我更新文本时,模型也更新了。 请参阅下面的示例 http://plnkr.co/edit/tknizoUTtheuOoAUZv4E?p=preview

【问题讨论】:

    标签: angularjs tabs kendo-ui


    【解决方案1】:

    Kendo 指令创建一个新范围。你需要有'。在你的 ng 模型中。推荐。

    app.controller("myCtrl", function ($compile, $scope) {
    $scope.o = {};
     $scope.o.testText = 'hello'
    $scope.o.testText2 = 'hello2'
    });
    

    在你看来

    <div id="tabstrip" kendo-tab-strip>
      <ul>
        <li class="k-state-active">Tab 1</li>
        <li>Tab 2</li>
      </ul>
    
      <div>
        <input type="text" ng-model="o.testText" />
      </div>
      <div>
        [Page 2]
      </div>
    </div>
        <div>
        <span>Tab Text </span></span><p>{{o.testText}}</p>
    
        </div>
        <span>Outside Tab Text </span>
        <input type="text" ng-model="o.testText2" />
        <p>{{o.testText2}}</p>
    
      </body>
    

    您可以在 Scope inheritance in Angular

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-20
      相关资源
      最近更新 更多