Is the ng-if directive malfunctioning?

After calling console.log($scope.showAddEvent), it is evident that the variable showAddEvent is being updated. However, the ng-if directive does not seem to reflect these changes as it does not display anything at all.

As I am relatively new to angularjs, I may be missing something...

html

<ion-footer-bar align-title="center" class="bar-positive" ng-if="$scope.showAddEvent == true">
      <div class="title" ng-click="modal.show()">Add Event</div>
  </ion-footer-bar>

controller.js

$scope.showAddEvent;

  var currentUser = Backand.getUserDetails().$$state.value;
  if (currentUser.role == "Admin" || currentUser.role == "Verified"){
      $scope.showAddEvent = true;
      console.log(currentUser.role);
      console.log('you can add event');
      console.log($scope.showAddEvent);
  }
  else {
      $scope.showAddEvent = false;
      console.log(currentUser.role);
      console.log('You cannot add Event');
    console.log($scope.showAddEvent);
  }

Answer №1

When creating your template, avoid mentioning scope. Update

<ion-footer-bar align-title="center" class="bar-positive" ng-if="$scope.showAddEvent == true">

to

<ion-footer-bar align-title="center" class="bar-positive" ng-if="showAddEvent">

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

ng-class is activated only when the form field is valid

I've been experimenting with the angular-fcsa-number directive, but I've noticed that the wrapper element of the input field isn't getting the 'has-error' class when the field is invalid. It appears that ng-class isn't recogni ...

Is it possible to refresh a div on one .aspx page using content from another .aspx page?

Just beginning my journey with asp.net and currently tackling a project that involves two .aspx pages. Events.aspx: This page is where the site admin can update upcoming events and webinars using an available panel to input event title, date, information ...

What is the proper method for determining the height of a scrollbar's grip?

Have you ever noticed that Facebook has a unique component on the right-most column? When the browser window is maximized, it looks like this: But when you resize your browser window to be smaller, it changes to this: The grip within the overflowing cont ...

Navigating the maze of Express.js routes

When attempting to use sendFile to call my index.html page, I encountered a problem. The issue is that the index.html page displays without any of the CSS or JS/jQuery effects applied. This is what my server.js file looks like: var express = require("exp ...

Structuring a Javascript project with a focus on component-based architecture

If I am following a component-based architecture and defining each component as an ES6 module, I organize all components in a /components folder. This folder is further divided into subfolders for grouped components. /js /components - header - ...

Tips for coordinating HTTP requests to coincide with the return of a promise

There is a Web API that retrieves data which needs to be used for creating a custom object. The challenge lies in the fact that the HTTP calls made are interdependent. Below is the code snippet where getLabMainAndLinesCombined() function contains 4 encapsu ...

Using a number input with step increments of 0.01 in AngularJS can result in undefined values for specific inputs

An issue arises when using a specific type of input in angularjs (1.6.1) where the values between 9.03 to 9.05 inclusively return undefined. This problem also occurs with other values like 9.62, 9.63, and 17.31. <input type="number" step="0.01" data-ng ...

Clicking the button becomes impossible after entering text and using `evaluateJavascript`

I am currently working on finding a solution to input the receipt number and click the 'Check Status' button on this specific website: After successfully entering the receipt number: document.getElementById('receipt_number').value = &a ...

What is the best way to save nested lists in a MYSQL database?

I am trying to figure out the best way to store this list of lists in MySQL, but I'm not sure how to go about it. list[x][y] contains items structured as {li:[{x:x,y:y}] , pos:{x:y}} list[x][y].li[z].x list[x][y].li[z].y list[x][y].pos.x list[x][y]. ...

Implementing Conditional Loops with $.each in AngularJS

I am working with an array called vm.settings.tab_permissions. Within this array, I need to check if the role is equal to vm.heading and replace it with vm.data. If the role is not equal, I want to push vm.data to vm.settings.tab. However, my current cod ...

Exploring Linked Data in JSON API Response with Rails API, Active Model Serializer, and Vue.js Single Page Application

I am working with data structured in a tree/hierarchical model for climbing areas, where they are connected through parent and child relationships. By utilizing the JSON API adapter along with my Active Model Serializer, class AreaSerializer < ActiveM ...

Execute JavaScript AJAX Request On Page Load

I am facing an issue with creating an onload event in which an AJAX function needs to be called and passed a value. The challenge lies in the fact that I have both my header and footer split into sections via PHP, therefore I cannot place it on the body ta ...

Resource loading unsuccessful: server returned a 401 status code for React webpage

( ) I'm currently working on a website dedicated to searching for GitHub users as part of my React course. However, I seem to be facing an issue with the website not fetching the response properly, possibly due to an Axios error. When searching for ...

Troubleshooting: ReactJS- Bootstrap Value Issue Not Displaying When Changing Tabs

I am currently working on a React App and utilizing react-bootstrap for development. However, I am encountering an issue where the content is only displaying correctly on the default nav item upon page refresh. When I switch to another nav item, the cont ...

The Vuetify rating system seems to be having trouble displaying

I've integrated the Vuetify rating component into my app (https://vuetifyjs.com/en/components/ratings#ratings), but I'm facing an issue. Despite having Vuetify 1.5.5 installed and working with other components like buttons, the stars in the ratin ...

using hover/click functionality with a group of DIV elements

I have a group of DIV elements that I want to apply an effect to when hovering over them with the mouse. Additionally, when one of the DIVs is clicked, it should maintain the hover effect until another DIV is clicked. <div class="items" id="item1"> ...

Merging Angular with jQuery: Organizing jQuery into a distinct file leads to the error message 'Property 'top' cannot be read because it is undefined.'

My project is based on AngularJS, and I've been trying to incorporate a jQuery code for a sticky sidebar feature. Strangely enough, when I tested my code on Plunkr, it works perfectly fine. However, when I try to implement it in my actual project, it ...

Is it possible to modify the local reference point of an object in three.js?

Is there a method to readjust the center point of an STL file once it has been relocated or turned? For example, if the original rotation of my object is set at (0,0,0), and then I rotate it to (20,70,90) degrees, is it possible to modify the local origi ...

Steps to fix the Error: connect EISCONN ::1:5555 - Local (:ffff.127.0.0.1:5555)

Currently, I am in the process of developing an Electron app where I need to establish a connection with a TCP port on my local machine. However, upon starting the application, I encounter the following error message: "A JavaScript error occurred in the ma ...

What is the best way to place a div on top of another div with a smooth

I am trying to achieve a specific effect where depending on certain conditions, one div appears overlapping another div from the right side. Below is the code I have been working on: const [loggedIn, setLoggedIn] = useState<boolean>(false); const ...