Angular UI Select2 reset error in console when used in chrome App

I am trying to use the following select2 example in a chrome app using AngularJS and Angular-UI . It works great, but unfortunately I get the following error in the Chrome console every time you click on the drop box.

"Refused to execute inline event handler because it violates the following content security policy directive:" default-src "self" chrome-extension-resource: ". Note that 'script -src' was not explicitly set, so 'default - src 'is used as a fallback. "

Any suggestion how I can fix this problem?

thank

* This code works fine without any problem in the browser, but not in Chrome. Code:

controller

 var app = angular.module("app", ['ui']);

function Ctrl($scope) {


    $scope.contacts = [
        {
        "id": 1,
        "name": "Lucky"},
       {
        "id": 2,
        "name": "Lance"},
    {
        "id": 3,
        "name": "Troels"},
    {
        "id": 4,
        "name": "Phe"}
    ];

}

      

View

<select class="input-medium" ui-select2 ng-model="form.cont" type="text" value="" >
    <option ng-repeat="contac in all" value="{{contac.id}}">{{contac.name}}</option>               
</select>

      

<h / "> Solved!
Thanks to the advice of @AlanRodriguesSoares. I downloaded another version of select2.js from gitub ([link] https://raw.github.com/timoxley/select2/bug/onclick/select2.js ) where this issue has been fixed.

+3


source to share


2 answers


Add the ng-csp directive to your element:

<html ng-app ng-csp>
...

      



With this directive, AngularJS will not use any of the forbidden dynamic JS code CSPs like eval and new Function.

0


source


If you look at select2.js, there are two onclick events set on the line, this is a known bug, try removing it. select.js lines 1524 and 2232.



0


source







All Articles