【发布时间】:2018-04-09 08:10:29
【问题描述】:
详情:
<div class="row-fluid">
<div ng-app="sampleAngular">
<div id="panel-1" ng-controller="Controller1">
<!-- some html code here that displays a table of information-->
</div>
<p><button type="button" onclick="onSubmit();" name="subscribe">Subscribe to Panel-2 Info</button> </p>
<div id="panel-2" ng-controller="Controller2">
<!-- some html code here that displays another table of information-->
</div>
</div>
</div>
问题: 只有当用户单击“订阅 Panel-2 信息”按钮时,才会显示 div id “panel-2”中的内容。该按钮应更新 DB 中的记录,然后在不刷新整个页面的情况下呈现 div id "panel-2" 中的内容。如何实现这个要求 - onSubmit() 函数中的任何 ajax 逻辑?
注意:我不应该渲染整个页面,然后在“panel-2”周围设置 visibility: false,因为我不应该调用控制器“ ng-controller="Controller2" 直到用户订阅(点击按钮)。
【问题讨论】:
标签: javascript html angularjs ajax