【问题标题】:Dynamic angular-strap modal template content动态角带模态模板内容
【发布时间】:2014-06-10 09:05:13
【问题描述】:

我想通过 http 服务获取 angular-strap 模态内容,并在服务完成后根据响应创建动态 html 内容,并以模态显示此内容。 简而言之,我需要一个事件,我可以在该事件上获取模态内容并显示获取的内容。

例如,我有一个用户列表,单击用户名时,我需要从服务器获取相应的用户详细信息,服务完成后,我需要以模式显示用户配置文件。

我尝试了下面的代码来创建 li,点击每个 li 我需要一个不同的模型,它是从服务器获取的

<li ng-repeat="category in subCategories" id="{{category.id}}" ng-class="getCategoryIndex(category) != -1 ? 'inactive' : 'active';"  ng-click="select_subCategory();"
                data-template="questions.html" data-placement="center" data-animation="am-fade-and-slide-top" bs-modal="modal"
            >
                <i class="fa fa-check-circle"></i> {{category.name}}<div class="checkbox cross"><input type="checkbox" id="box_{{category.id}}" /><label for="box_{{category.id}}"></label></div>
            </li>

其中 questions.html 是一个静态模板,对于静态模板可以正常工作,但我将如何根据 li 标题从服务器获取它?

静态模板加载为:

<script type="text/ng-template" id="questions.html">
    ...
</script>

如何根据点击的li制作模板?

【问题讨论】:

  • 我有类似的问题

标签: angularjs angularjs-ng-repeat angular-ui


【解决方案1】:

在角运动中,我们可以直接改变 ng-bind 对象,如下所示:

$scope.change_content = function(){

      $scope.aside = {title: 'Custom Title', content: 'Hello Custom Aside<br />This content can be fetched through an ajax request!'};
      $scope.modal = {title: 'Custom Title', content: 'Hello Custom Modal<br />This content can be fetched through an ajax request!'};
      var el = document.getElementById('trigger');
      angular.element(el).triggerHandler('click');
  };

【讨论】:

    猜你喜欢
    • 2014-06-30
    • 1970-01-01
    • 1970-01-01
    • 2014-03-18
    • 1970-01-01
    • 2020-03-16
    • 2016-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多