Home > Web Front-end > JS Tutorial > body text

How to solve file error after angularjs compression

php中世界最好的语言
Release: 2018-03-28 15:24:15
Original
2053 people have browsed it

This time I will bring you how to solve the file error after compression in angularjs. What are the precautions to solve the problem of file error after compression in angularjs. The following is a practical case. Let’s take a look. one time.

The reason for the problem is that after compression, variablesbecome,e,s,t,etc., the method that requires dependency injection does not use square bracket injection, and in Used directly in function parameters, resulting in the inability to identify modules that require dependency injection after compression. For example:

var module= angular.module('homeApp', ['ui.router']); 
module.config(function ($sceProvider) { 
 $sceProvider.enabled(false); 
})
Copy after login

is changed to:

var module= angular.module('homeApp', ['ui.router']); 
module.config(['$sceProvider',function ($sceProvider) { 
 $sceProvider.enabled(false); 
}])
Copy after login

After using gulp-uglify compression again, the execution is normal.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to implement the starry navigation bar in JS

How vue and vue-i18n implement background data Multi-language switching

The above is the detailed content of How to solve file error after angularjs compression. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!