【问题标题】:Add component dynamically with ionic使用 ionic 动态添加组件
【发布时间】:2016-09-26 01:04:32
【问题描述】:

我想知道有没有办法动态添加组件,因为我想做的是: 当我点击我的按钮时,它会触发一个函数,在我的 html 中添加一个具有这些属性的新选择器:

 <select ng-change="test(selectedId)" ng-model="selectedId" ng-options="id.id as id.pseudo for id in idList"> </select>

和按钮:

<button ng-click="addSelector()">add selector</button>

【问题讨论】:

    标签: angularjs ionic-framework components


    【解决方案1】:

    你的控制器中的代码应该像这样定义一个点击处理程序:

       $scope.idList = ['first element', 'second element'];
       $scope.addSelector = function(){
         $scope.idList.push('new element');
       }
    

    【讨论】:

      猜你喜欢
      • 2020-08-21
      • 2019-05-13
      • 1970-01-01
      • 2014-10-02
      • 2012-01-03
      • 2012-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多