popover不使用angularjs在onsen ui中工作

时间:2015-10-05 06:58:17

标签: javascript angularjs onsen-ui

我已经在onsenui上做了一个演示,我需要在这里使用 popover ,我已经搜索过并在onsen ui本身找到了popover的支持,所以我按照下面的步骤进行了尝试链路,popover in onsen ui

HTML

但它不起作用并在控制台中说“ TypeError:href为null ”,我的代码如下, 的 HTML

<ons-page ng-controller="listingController">
    <ons-toolbar style="background: #da1e3e;">

   <div class="left">
     <ons-back-button>Back</ons-back-button>
   </div>

        <div class="center">Listing</div>

   <div class="right">
     <span class="toolbar-button--quiet navigation-bar__line-height" ng-click="gallery.pushPage('filter.html');" style="border: none; padding: 0 0 4px 0;">
       <i class="ion-android-options" style="font-size:24px; color: #FFFFFF;"></i>
     </span>
<!--      <span class="toolbar-button--quiet navigation-bar__line-height"  ng-click="toggleModal('Success')" >-->
           <span class="toolbar-button--quiet navigation-bar__line-height"  ng-click="show('#navigation')" >-->
         <i class="ion-android-more-vertical" style="font-size:26px;"></i>
       </span>
        <modal visible="showModal"  >
     <ul>
       <h4 align="left">Featured</h4>
  <h4 align="left">Name(A-Z)</h4>
  <h4 align="left">Rating</h4>
 <h4 align="left">Most Popular</h4>
     </ul>
  </modal>
   </div>
 </ons-toolbar>

    <div class="app-page" >
   <div class="list-wrap">
    <ons-list class="list ons-list-inner list--categories" modifier="categories">
        <div ng-bind-html="deliberatelyTrustDangerousSnippet()"></div> 

    </ons-list>
   </div>
  </div>



</ons-page>  

<script type="text/ons-template" id="popover.html">
  <ons-popover direction="up down" cancelable>
    <div style="text-align: center; opacity: 0.5;">
      <p>This is a popover!</p>
      <p><small>Click the background to remove the popover.</small></p>
    </div>
  </ons-popover>
</script>

JS

ons.createPopover('popover.html').then(function(popover) {
    $scope.popover = popover;
  });

请帮我保存..谢谢

1 个答案:

答案 0 :(得分:0)

根据我的知识,应该使用模板。请参考以下代码

HTML

Date

JS

<div class="navigation-bar__right" ng-controller="myPopoverController">
    <ons-icon class="button button--quiet" icon="ion-ios-information-outline" size="20px" fixed-width="false" ng-click="popover.show($event)"></ons-icon>
</div>
<ons-template id="myPopover.html">
    <ons-popover cancelable direction="down">
        <div style="text-align: center;">
            <ons-list>
                <ons-list-item>List 1</ons-list-item>
                <ons-list-item>List 2</ons-list-item>
                <ons-list-item>List 3</ons-list-item>
            </ons-list>
        </div>
    </ons-popover>
</ons-template>