Anglular gives access denied to mymodal.html

Potney Switters

I have a controller where I define a function along with it's template. It is a modal that needs to pop-up. No modal pops up and access denied for mymodal.html.

My controller/app:

angular.module('myApp').controller('MyCtrl',function (
...
...
...
$scope.removeComment = function (reply) {
  var myModalInstance = $modal.open({
    scope: $scope,
    templateUrl: 'mymodal.html',
    controller: function ($scope, $modalInstance, reply) {

in the template I am including:

<div ng-app="myApp" ng-controller='MyCtrl'>

What can be wrong?

ababashka

I think problem is in your controller function: reply is not defined, i suppose. If you will open console, i think you will see something like this:

Error: [$injector:unpr] Unknown provider: replyProvider <- reply

If you want to inject something into your controller, you can write some service.

BTW, if you are going to use some minificator you will see errors, because when you define controller by this way and minificate your code - your injections will be minificated too.

Better way is to do something like this:

var app = angular.module('app', ['ui.bootstrap']);
app.controller('MyCtrl', ['$scope', '$modal', function ($scope, $modal) {
  $scope.removeComment = function (reply) {
    var myModalInstance = $modal.open({
      scope: $scope,
      templateUrl: 'mymodal.html',
      controller: 'modalController',
      ...
      });
    };
/* SOME CODE HERE */
}]);

and

app.controller('modalController', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
  /* SOME LOGIC HERE */
}]);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Nuget add packages gives access denied errors

Why the prompt gives me "Access denied"?

Debug in Visual Studio 2017 gives access denied

accessing path through cloudfront gives access denied

Working command in a plain Powershell prompt gives Access denied in a PSSession

Hosting ASP.NET in IIS7 gives Access is denied?

signed applet gives AccessControlException: access denied, when calling from javascript

vscode installed in other directory gives access denied error

New-SelfSignedCertificate to create certificate gives Access Denied

"Access is denied" with NUL > index.html command

requests_html render returns Access Denied

Access Denied to html resources from spring security

using pdf.js' viewer.html gives NS_ERROR_DOM_BAD_URI: Access to restricted URI denied when accessing it from

Setting window.location or window.open in AngularJS gives "access is denied" in IE 11

Build Solution in Visual Studio 2015 gives error "Error generating Win32 resource: Access is denied"

Overwrite directory with shutil.rmtree and os.mkdir sometimes gives 'Access is denied' error

mysqlfailover command gives Error 1045: Access denied for user 'root'@'localhost' (using password: NO)

Angular application hosted on AWS redirection gives access denied having cloudfront ahead of S3

Google Container Registry gives access denied when trying to push docker container

Running dockerd gives error "open //./pipe/docker_engine: Access is denied." (Windows Server 1709)

User.IsInRole() returns false and Authorize Roles gives me an Access Denied

I created a subdomain and when I try to reach it , it gives access denied error

Firefox: Error: Access to 'about:text/html' from script denied

Access Denied When using php to link to another html page

apk tool gives permission denied

CDIR= $(pwd) gives "Permission denied"

OS call gives permission denied

Android Q (API level 29) doesn't load HTTPS websites. Gives error: (net::ERR_ACCESS_DENIED)

Access denied for token revoke

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive