Troubleshooting issues with popover functionality in Onsen UI when using AngularJS

I have created a demo using Onsen UI and I am trying to incorporate a popover into it. After researching, I found that there is built-in support for popovers in Onsen UI itself. I followed the steps outlined in the link below: Onsen UI Popover

HTML

However, when I implemented it, I encountered an error saying "TypeError: href is null" in the console. My code snippet is as follows:

<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>

JavaScript (JS)

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

Please assist me in resolving this issue. Thank you.

Answer №1

Based on my understanding, ons-popovers should be included in a template. Please take a look at the code snippet below:

HTML

<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> 

JS

myApp.controller('myPopoverController', function ($scope) {

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using regex to confirm prices are accurate

Can anyone assist me with validating input using regEx in Vue? I'm struggling to create one and haven't been able to find the correct pattern online for what I need. The specific validation I am attempting is for a price value that should be a f ...

Updating label values to default in JavaScript/jQuery

I need to utilize jQuery/js for the following tasks: Extract label values from form inputs Insert those labels as input values in the corresponding fields Conceal the labels It's a simple task. Instead of manually entering each label like this: $( ...

Resolving the "TypeError: Unable to access the 'then' property of undefined" issue in Node.js

I am currently working on connecting my app to a third party API using a node module. Below is the code I am utilizing for a school project. The library I am using to request data from the API can be found here. Note: This package is not being maintained ...

Ways to boost memory capacity in nodejs

I've been attempting to increase the memory limit in node.js, and to do so I added an environment variable. You can see how I did it here Unfortunately, it doesn't seem to be working as expected. I even tried using capital letters with no succe ...

The feature of Google street view is not supported within the tabs on WordPress

I'm experiencing some issues with displaying Google maps and street view using the Wp Google Map WordPress plugin within tabs. The map displays perfectly on the first tab where I placed the short code for the map, but on the second tab where I placed ...

Getting an error in AngularJS with $http.get: "TypeError: boolean is not a function"

I've implemented angularjs $http.get in a factory to make an API call. When I ran my angularjs application, it successfully returned the data. However, upon inspecting the console using F12, I encountered the following error: "TypeError: boolean is n ...

What is the best way to transform a string resembling JSON or a JS object into a valid JS object?

The specific String in question was originally part of a JavaScript object as shown below: var nameVal = "Jacob"; var favNumbersVal = "{\"firstNum\":0, \"secondNum\":1, \"thirdNum\":2}"; var aJSObject = { "name" = nameV ...

Generate a commitment from the function

I know the basics of JavaScript Promise and promise chain, but I'm looking to deepen my understanding. For example, take a look at the method provided below. It's in TypeScript, but can be adjusted for JavaScript ES6. private InsertPersonInDB(p ...

Verify the select box for accuracy when its value is changed

When using the native checkValidity() method on the HTMLSelectElement, I have encountered some issues in non-Firefox browsers. JSFiddle JavaScript $(document).on('change', 'select', function () { alert(this.checkValidity()); }); ...

Extracting Client's True IP Address using PHP API

Utilizing the following api: I am able to retrieve country, city, and real IP address in localhost (127.0.0.1) successfully. However, when I implement this code on my website, it displays the server's address instead of the client's. How can I r ...

When I click on it, my div refuses to slide down

Help needed with creating a drop-down menu on my small website. Having trouble getting the desired slideDown effect to work, even though other animations are functioning fine. The text on the div reads "Menu". Below is the jQuery code: $(document).ready ...

Tips for utilizing AJAX to send data from a specific row

<table> <tr data-id="1"> <input type="text" name="name_1" value="abc"> <input type="text" name="value_1" value="1"> <a href="load_edit_row(this)">Edit</a> </tr> <tr data-id="2"> <input t ...

Why is the updated index.html not loading with the root request?

I'm currently working on an Angular app and facing an issue with the index.html file not being updated when changes are made. I have noticed that even after modifying the index.html file, requests to localhost:8000 do not reflect the updates. This pro ...

Tips for sending a successful POST request with the MEAN stack

Currently, I am utilizing yeoman to set up a new project. My ultimate goal is to master the process of scaffolding CRUD operations. However, I have encountered an issue with a post request. For this reason, I opted for the angular-fullstack generator as I ...

Sort the array by the value of a specific property

I am working with a JSON file that contains 13k objects. My goal is to extract only the objects that have the event { name: "Submitted"}. The events property in each object is an array that includes multiple name properties. Below is a visual representatio ...

Errors in Intellisense detected within the latest Node Tools Express App development project

After setting up a new project with the "Basic Node.js Express 4 Application" template, I noticed some errors have already surfaced: https://i.sstatic.net/8jbYt.png Could this be a Visual Studio issue? Any pointers on resolving these errors? ...

How can I implement jQuery autocomplete with customized settings?

In my Drupal project, I am looking to implement jQuery's auto complete feature to search for nodes based on their titles. I am having trouble finding examples that align with my specific requirements: The URL structure should be: /api/node/title/{wh ...

Ways to assign numerical values to vertical bars using HTML and CSS

Is there a way to create a Y-axis style line in HTML and CSS that looks like an actual Y-axis? I've attempted the following approach, which technically works but doesn't have the desired appearance. #mySpan{ writing-mode: vertical-lr; ...

What is the best method for implementing click functionality to elements that share a common class using only pure JavaScript

I am struggling to figure out how to select specific elements with the same classes using only pure JavaScript (no jQuery). For example: <div class="item"> <div class="divInside"></div> </div> <div class= ...

Why isn't my ajax success data showing up in AngularJS?

Currently, I am working on calling ajax to retrieve my HTML content. However, I am encountering an issue when trying to display that data in a tooltip or popover. Even though I can see the data in the console, the tooltip is showing up as black. I am not s ...