Encountering the '$sce' error with an unknown provider in AngularJS version 1.2.3

I have been using AngularJS 1.2.3, which is supposed to automatically enable the SCE service. Nevertheless, I am encountering the following error:

http://errors.angularjs.org/1.2.3/$injector/modulerr?p0=SaveApp&p1=Error: [$injector:unpr]   
http://errors.angularjs.org/1.2.3/$injector/unpr?p0=%24sce 
at Error (native)

Here is a snippet of my code:

var AwesomeApp = angular.module('AwesomeApp', ['ngCookies', 'ngSanitize', 'ngRoute', 'ui.bootstrap', 'ui.router'], function($httpProvider, $dialogProvider) {

Further down in the code:

AwesomeApp.config(['$routeProvider', '$compileProvider', '$sce', function($routeProvider, $compileProvider, $sce) {

$routeProvider.
    when('/', {templateUrl: $sce.getTrustedResourceUrl(chrome.extension.getURL('app.html')),   controller: 'searchResultsController'}).
    otherwise({redirectTo: '/'});

Any insights on why this Unknown Provider error is occurring?

Answer №1

$sce is not a provider but a service

In config blocks, only providers can be injected, not services.

If you want to whitelist URLs, you can inject $sceDelegateProvider and define the whitelist like this:

.config(function($sceDelegateProvider){

  $sceDelegateProvider.resourceUrlWhitelist(['self','http://*.url.com/**']);

})

Refer to the $sceDelegateProvider documentation:

The $sceDelegateProvider provider allows developers to configure the $sceDelegate service. Developers can set whitelists and blacklists for secure sourcing of Angular templates.

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

Encountering undefined outcomes when iterating over a JSON Array

After receiving a JSON String in a response variable through an AJAX request, I need to parse it: The JSON data { "TheArray":[ { "AlmostThere": { "whatWeAreLookingFor":"Hello" } }, { "Almos ...

Using PHP and JavaScript to enhance functionality around a hyperlink

I am trying to incorporate a small piece of Javascript on my website to ensure user confirmation. While I have successfully used the 'onclick' function with buttons, I am facing difficulty implementing it on a link. Here is the link in question: ...

identifying which specific button was clicked using JavaScript/jQuery

All of the buttons on my page are identical - same title, same value, everything is the same. Is there a way for me to identify which specific button was clicked? ...

What is the best way to retrieve all the names stored within a nested object?

I am currently delving into the realm of JavaScript and my instructor has given me an exercise to create a function that will output an array containing all the names from the nested object below: { name: 'grandma', daughter: { name: &ap ...

Ajax experiences trouble with a intricate sequence of characters

How can I successfully send the following string to a spring MVC controller using ajax: (?=^.{8,}$)(?=.+\d)(?=.+[!@#$%^&]+)(?!.*[\n])(?=.+[A-Z])(?=.+[a-z])$ I am encountering a 400 bad request error and it is not leaving the client side. An ...

Encountering a sudden problem while running gulp build due to a node_module - Surprising occurrence of Unexpected

Encountering an unexpected issue while running a gulp build process for a web app that I am struggling to resolve. The problem did not exist on the evening of 25/01/2019, but when attempting to execute the gulp build process this morning (30/01/2019), an ...

Is the JavaScript code not executing properly?

There seems to be an issue with this code as it's not displaying an unordered list of HTML elements as intended. I've written the script and HTML code using Sublime Text, but even after trying to run the script in Chrome's developer console ...

Endless time continuum within the scheduling application

Looking for a way to make the time axis in my scheduling app infinite? Currently, it has a fixed length, but I want users to be able to scroll endlessly into the past or future. Any suggestions on how to achieve this? Check out this JSBin for a basic exam ...

Numerous sections with tabs on the webpage

I am in need of incorporating multiple tabbed sections on a single page, but unfortunately they are currently interconnected. When one tab is clicked, it impacts the others. To see this issue in action, you can visit: https://jsfiddle.net/pxpsvoc6/ This ...

Trouble with VueJS: @change event not triggered when <input> value changes

In my VueJS project, I am working with two separate components: One is a modal and the other is a form. Within the modal component, the user inputs a PIN which is then confirmed. This value is then set to an input tag in the form component to save it. T ...

Is it possible to dynamically assign and call functions through an Object in Angular 6?

I implemented a click handler for a button that is generated dynamically. Within the click handler function, I am invoking a callback function. However, I encountered an issue where an error message popped up stating that "Callback function is not a fu ...

Creating an HTML table using elements from a complex Javascript array through the process of "element reduction"

I have a new project that I am working on, and it involves dealing with arrays in JavaScript. In my code, I have four arrays declared as follows: var ROW1 = ['module1']; var ROW2 = ['module2', 'module3']; var ROW3 = ['m ...

After reaching the conclusion, the code restarts

Any ideas on how to reset this code every 10-20 seconds? I'm struggling to find a solution! I'm new to coding, so any assistance would be greatly appreciated. Here's the code: var items = document.getElementsByClassName('btn-primary n ...

Switch between various API content upon clicking (JavaScript)

Upon receiving data from an API in JSON format using PHP, I aim to incorporate a filter mechanism for displaying distinct content sourced from the API. For instance, by specifying a filter in my API call, I can retrieve separate datasets such as one with ...

Filtering text for highlighting in Vue.js is a breeze

Struggling to create a text highlight filter using vuejs. The task involves iterating through an array of words, highlighting any matches with a span and class. However, I'm facing difficulty in getting the data to return with proper HTML formatting i ...

Discover the underlying data within a nested JSON structure and track back to identify the corresponding values

In the JSON structure provided below, Suppose I have the chapter "number" and section "number". What is the most efficient way to search and trace backwards starting from what I already know, in order to find the "number" of the title within titles and t ...

How to iterate through a "for" loop in JavaScript using Python-Selenium?

In my current project, I am utilizing Javascript to gather data from an HTML page using Selenium. However, I am facing a challenge where I am unable to execute the multi-line for loop in the Javascript portion on my computer through Selenium with Python (S ...

What could be causing my textarea-filling function to only be successful on the initial attempt?

Programming: function updateText() { $("body").on("click", ".update_text", function(event) { $(this).closest("form").find("textarea").text("updated text"); event.preventDefault(); }); } $(document).ready(function() { updateText(); }); H ...

The functionality of WrapAll is not functioning properly in React JS

$('p').wrapAll($('<div class="wrapper"></div>')); .wrapper { background: #EEE; margin: 10px; padding: 5px; border: 1px solid black; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery. ...

Error Encountered in Jhipster Application During Initial Launch

Struggling with running a newly generated Jshipster 3 application using gulp serve after successful generation. My setup includes Ubuntu 16.04 and npm 3.9, but I keep encountering an error when attempting to execute gulp serve: check out this screenshot ...