Angular has some features that can break certain CSP (Content Security dịch - Angular has some features that can break certain CSP (Content Security Việt làm thế nào để nói

Angular has some features that can

Angular has some features that can break certain CSP (Content Security Policy) rules.

If you intend to implement these rules then you must tell Angular not to use these features.

This is necessary when developing things like Google Chrome Extensions or Universal Windows Apps.

The following rules affect Angular:

unsafe-eval: this rule forbids apps to use eval or Function(string) generated functions (among other things). Angular makes use of this in the $parse service to provide a 30% increase in the speed of evaluating Angular expressions.

unsafe-inline: this rule forbids apps from inject custom styles into the document. Angular makes use of this to include some CSS rules (e.g. ngCloak and ngHide). To make these directives work when a CSP rule is blocking inline styles, you must link to the angular-csp.css in your HTML manually.

If you do not provide ngCsp then Angular tries to autodetect if CSP is blocking unsafe-eval and automatically deactivates this feature in the $parse service. This autodetection, however, triggers a CSP error to be logged in the console:

Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of
script in the following Content Security Policy directive: "default-src 'self'". Note that
'script-src' was not explicitly set, so 'default-src' is used as a fallback.
This error is harmless but annoying. To prevent the error from showing up, put the ngCsp directive on an element of the HTML document that appears before the tag that loads the angular.js file.

Note: This directive is only available in the ng-csp and data-ng-csp attribute form.

You can specify which of the CSP related Angular features should be deactivated by providing a value for the ng-csp attribute. The options are as follows:

no-inline-style: this stops Angular from injecting CSS styles into the DOM

no-unsafe-eval: this stops Angular from optimizing $parse with unsafe eval of strings

You can use these values in the following combinations:

No declaration means that Angular will assume that you can do inline styles, but it will do a runtime check for unsafe-eval. E.g. . This is backwardly compatible with previous versions of Angular.

A simple ng-csp (or data-ng-csp) attribute will tell Angular to deactivate both inline styles and unsafe eval. E.g. . This is backwardly compatible with previous versions of Angular.

Specifying only no-unsafe-eval tells Angular that we must not use eval, but that we can inject inline styles. E.g. .

Specifying only no-inline-style tells Angular that we must not inject styles, but that we can run eval - no automatic check for unsafe eval will occur. E.g.

Specifying both no-unsafe-eval and no-inline-style tells Angular that we must not inject styles nor use eval, which is the same as an empty: ng-csp. E.g.
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Mô men có một số tính năng mà có thể phá vỡ một số quy tắc CSP (chính sách bảo mật nội dung).Nếu bạn muốn thực hiện những quy tắc này sau đó bạn phải nói với góc không để sử dụng các tính năng này.Điều này là cần thiết khi phát triển những thứ như Google Chrome phần mở rộng hoặc ứng dụng Windows phổ quát.Các quy tắc sau ảnh hưởng đến góc:không an toàn eval: quy tắc này cấm ứng dụng để sử dụng eval hoặc Function(string) tạo ra chức năng (trong số những thứ khác). Góc làm cho sử dụng điều này trong dịch vụ $parse để cung cấp một tăng 30% tốc độ đánh giá biểu thức góc.không an toàn nội tuyến: quy tắc này cấm các ứng dụng từ bơm phong cách tuỳ chỉnh vào tài liệu. Góc sử dụng này để bao gồm một số quy tắc CSS (ví dụ như ngCloak và ngHide). Để thực hiện các chỉ thị làm việc khi một quy tắc CSP chặn kiểu, bạn phải liên kết với góc csp.css trong HTML của bạn theo cách thủ công.Nếu bạn không cung cấp ngCsp sau đó góc cố gắng phát hiện tự động nếu CSP chặn không an toàn eval và tự động deactivates tính năng này trong dịch vụ $parse. Này phát hiện tự động, Tuy nhiên, gây ra một lỗi CSP để đăng nhập vào giao diện điều khiển:Từ chối để đánh giá một chuỗi như dung JavaScript vì 'không an toàn eval' không phải là một nguồn cho phép củaCác kịch bản trong chỉ thị chính sách bảo mật nội dung sau đây: "mặc định-src 'tự'". Lưu ý rằng'script-src' không được thiết lập một cách rõ ràng, do đó, 'mặc định-src' được sử dụng như một dự phòng.Lỗi này là vô hại nhưng gây phiền nhiễu. Để ngăn chặn lỗi từ Hiển thị, đặt chỉ thị ngCsp trên một phần tử của các tài liệu HTML mà xuất hiện trước khi các tag that loads the angular.js file.

Note: This directive is only available in the ng-csp and data-ng-csp attribute form.

You can specify which of the CSP related Angular features should be deactivated by providing a value for the ng-csp attribute. The options are as follows:

no-inline-style: this stops Angular from injecting CSS styles into the DOM

no-unsafe-eval: this stops Angular from optimizing $parse with unsafe eval of strings

You can use these values in the following combinations:

No declaration means that Angular will assume that you can do inline styles, but it will do a runtime check for unsafe-eval. E.g. . This is backwardly compatible with previous versions of Angular.

A simple ng-csp (or data-ng-csp) attribute will tell Angular to deactivate both inline styles and unsafe eval. E.g. . This is backwardly compatible with previous versions of Angular.

Specifying only no-unsafe-eval tells Angular that we must not use eval, but that we can inject inline styles. E.g. .

Specifying only no-inline-style tells Angular that we must not inject styles, but that we can run eval - no automatic check for unsafe eval will occur. E.g.

Specifying both no-unsafe-eval and no-inline-style tells Angular that we must not inject styles nor use eval, which is the same as an empty: ng-csp. E.g.
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Góc có một số tính năng mà có thể phá vỡ một số CSP (Content Security Policy) quy tắc. Nếu bạn có ý định thực hiện những quy định sau đó bạn phải nói với góc không sử dụng các tính năng này. Điều này là cần thiết khi phát triển những thứ như mở rộng của Google Chrome hoặc Universal Windows Apps. Các quy tắc sau đây ảnh hưởng đến góc: không an toàn-eval: quy luật này cấm các ứng dụng để sử dụng eval hoặc Function (string) tạo ra các chức năng (trong số những thứ khác). Góc làm cho việc sử dụng này trong các dịch vụ $ phân tích cú pháp để cung cấp một sự gia tăng 30% trong tốc độ của đánh giá biểu thức góc cạnh. Không an toàn-inline: quy luật này cấm các ứng dụng từ phong cách tùy chỉnh bơm vào tài liệu. Góc làm cho việc sử dụng này bao gồm một số quy tắc CSS (ví dụ như ngCloak và ngHide). Để thực hiện các chỉ thị làm việc khi một quy tắc CSP là chặn phong cách nội tuyến, bạn phải liên kết với góc-csp.css trong HTML của bạn bằng tay. Nếu bạn không cung cấp ngCsp sau đó cố gắng góc để autodetect nếu CSP là chặn không an toàn-eval và tự động ngưng hoạt động tính năng này trong các dịch vụ phân tích cú pháp $. Dò này, tuy nhiên, gây ra một lỗi CSP cần đăng nhập vào giao diện điều khiển: Từ chối để đánh giá một chuỗi như JavaScript vì 'không an toàn-eval' không phải là một nguồn cho phép các kịch bản trong các chỉ thị Chính sách bảo mật nội dung sau đây: "default-src 'tự '". Lưu ý rằng 'kịch bản-src' không được thiết lập một cách rõ ràng, do đó, 'mặc định-src' được sử dụng như là một dự phòng. Lỗi này là vô hại nhưng gây khó chịu. Để ngăn chặn các lỗi hiển thị lên, đưa các chỉ thị ngCsp trên một phần tử của tài liệu HTML xuất hiện trước khi
















tag that loads the angular.js file.

Note: This directive is only available in the ng-csp and data-ng-csp attribute form.

You can specify which of the CSP related Angular features should be deactivated by providing a value for the ng-csp attribute. The options are as follows:

no-inline-style: this stops Angular from injecting CSS styles into the DOM

no-unsafe-eval: this stops Angular from optimizing $parse with unsafe eval of strings

You can use these values in the following combinations:

No declaration means that Angular will assume that you can do inline styles, but it will do a runtime check for unsafe-eval. E.g. . This is backwardly compatible with previous versions of Angular.

A simple ng-csp (or data-ng-csp) attribute will tell Angular to deactivate both inline styles and unsafe eval. E.g. . This is backwardly compatible with previous versions of Angular.

Specifying only no-unsafe-eval tells Angular that we must not use eval, but that we can inject inline styles. E.g. .

Specifying only no-inline-style tells Angular that we must not inject styles, but that we can run eval - no automatic check for unsafe eval will occur. E.g.

Specifying both no-unsafe-eval and no-inline-style tells Angular that we must not inject styles nor use eval, which is the same as an empty: ng-csp. E.g.
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2025 I Love Translation. All reserved.

E-mail: