Rectangle 27 147

You don't. The server you are making the request to has to implement CORS to grant JavaScript from your website access. Your JavaScript can't grant itself permission to access another website.

Make the requests to Flickr from your server instead.

I am not using a server but I can use node.js. Can you show me the way with this?

Not in the space available in a comment. It's rather a big set of topics.

A great guide for enabling CORS can be found here : enable-cors.org

@AlexLeung Postman is an installed application. If your website could make my browser request data from Google and read it, then your website could request my GMail Inbox page and read all of my email. That would be terrible.

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 147

You don't. The server you are making the request to has to implement CORS to grant JavaScript from your website access. Your JavaScript can't grant itself permission to access another website.

Make the requests to Flickr from your server instead.

I am not using a server but I can use node.js. Can you show me the way with this?

Not in the space available in a comment. It's rather a big set of topics.

A great guide for enabling CORS can be found here : enable-cors.org

@AlexLeung Postman is an installed application. If your website could make my browser request data from Google and read it, then your website could request my GMail Inbox page and read all of my email. That would be terrible.

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 144

You don't. The server you are making the request to has to implement CORS to grant JavaScript from your website access. Your JavaScript can't grant itself permission to access another website.

Make the requests to Flickr from your server instead.

I am not using a server but I can use node.js. Can you show me the way with this?

Not in the space available in a comment. It's rather a big set of topics.

A great guide for enabling CORS can be found here : enable-cors.org

@AlexLeung Postman is an installed application. If your website could make my browser request data from Google and read it, then your website could request my GMail Inbox page and read all of my email. That would be terrible.

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 2

You could use ng-disabled directive here which would enable and disable the dropdown

<a><button ng-click="enabled=true">search</button></a>

<select ng-model="test" ng-disabled="!enabled">
    <option value="">A</option>
    <option value="">B</option>
    <option value="">C</option>
    <option value="">D</option>
</select>
<select ng-model="test1" ng-disabled="!enabled">
    <option value="">1</option>
    <option value="">2</option>
    <option value="">3</option>
    <option value="">4</option>
    <option value="">5</option>
</select>

Thanks Pankaj. But this will only disable the drop-down, while want to show drop-down list(not drop-down menu) only after search is clicked , and not only that want to show list of drop-down directly when clicked on search button.

angularjs - Using angular, Show drop-down list only when search button...

angularjs
Rectangle 27 3

In ui-grid you have to enable cell-navigation in your markup:

<div ng-controller="MainCtrl">
  <div ui-grid="gridOptions" ui-grid-cellNav></div>
</div>

Works fine. Do you by any chance know how to do a full-row select instead of selecting a cell?

You mean highlighting the full row while navigating? I'm not sure how to do this. Maybe by changing the row template or using the onNavigate event. I'll have a look at this, but since I'm also pretty new to ui-grid (and drowning in work) I think it's better to open a new question.

angularjs ui-grid 3.0 key navigation - Stack Overflow

angularjs ng-grid angular-ui-grid
Rectangle 27 2

It seems to me, that your code works fine without watcher you have added. I hope I understood what you want correctly. Try this snippet:

angular
    .module('app', [])
    .controller('Ctrl', function($scope) {
        $scope.qualiLevel = [
          {quali_level: 'A', qualification_id: 1},
          {quali_level: 'B', qualification_id: 2}
        ];
    });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>

<div ng-app="app">
<div ng-controller="Ctrl">
  
<div class="form-group">
    <label class="col-lg-2 col-md-3 control-label">Qualification</label>
        <div class="col-lg-10 col-md-9">
            <div class="radio-custom radio-inline">
                <input type="radio" ng-model="QualificationDetails.qualification_type" value="edu" name="radio1" id="radio4">
                    <label for="radio4">Educational</label>
            </div>
            <div class="radio-custom radio-inline">
                <input type="radio" ng-model="QualificationDetails.qualification_type" value="prof" name="radio1" id="radio5">
                    <label for="radio5">professional</label>
            </div>
        </div>
</div>

<div class="form-group">
    <label class="col-sm-2 control-label" for="Qulitype">Qualification type</label>
        <div class="col-sm-10">

            <select name="repeatSelect" id="repeatSelect" ng-disabled="QualificationDetails.qualification_type == 'prof'" ng-model="QualificationDetails.qualification" class="form-control">
                <option ng-repeat="quali in qualiLevel" value="{{quali.qualification_id}}">{{quali.quali_level}}</option>
            </select>
        </div>
</div>
</div>
</div>

Also how do I clean the drop downlist value once I mark the professional radio button?

QualificationDetails.qualification_type
ng-change
$watch

I answered the question using the $watch. Thanks for the tip. :)

javascript - How to enable disable a select drop down list using radio...

javascript html angularjs
Rectangle 27 51

I had a similar problem and for me it boiled down to adding the following HTTP headers at the response of the receiving end:

Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Origin: *

You may prefer not to use the * at the end, but only the domainname of the host sending the data. Like *.example.com

But this is only feasible when you have access to the configuration of the server.

I am new in AngularJs. Please can you tell me where to implement this?

@Ankit You need to add these headers in the server, not in AngularJS.

Voted up for the last statement: "But this is only feasible when you have access to the configuration of the server"

@techcraver - You dont need operational access to the configuration of the server - just pass the headers from within your script. If you have a PHP backend it would be header('Access-Control-Allow-Origin: *');

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 51

I had a similar problem and for me it boiled down to adding the following HTTP headers at the response of the receiving end:

Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Origin: *

You may prefer not to use the * at the end, but only the domainname of the host sending the data. Like *.example.com

But this is only feasible when you have access to the configuration of the server.

I am new in AngularJs. Please can you tell me where to implement this?

@Ankit You need to add these headers in the server, not in AngularJS.

Voted up for the last statement: "But this is only feasible when you have access to the configuration of the server"

@techcraver - You dont need operational access to the configuration of the server - just pass the headers from within your script. If you have a PHP backend it would be header('Access-Control-Allow-Origin: *');

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 50

I had a similar problem and for me it boiled down to adding the following HTTP headers at the response of the receiving end:

Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Origin: *

You may prefer not to use the * at the end, but only the domainname of the host sending the data. Like *.example.com

But this is only feasible when you have access to the configuration of the server.

I am new in AngularJs. Please can you tell me where to implement this?

@Ankit You need to add these headers in the server, not in AngularJS.

Voted up for the last statement: "But this is only feasible when you have access to the configuration of the server"

@techcraver - You dont need operational access to the configuration of the server - just pass the headers from within your script. If you have a PHP backend it would be header('Access-Control-Allow-Origin: *');

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 1

As the control is radiobutton, your QualificationDetails.qualification_type value will be set to 1 or 0 and not to the label value. You have to have different variables for two radio buttons. Based on their value you have to set QualificationDetails.qualification_type = 'prof' or something

javascript - How to enable disable a select drop down list using radio...

javascript html angularjs
Rectangle 27 9

var MyApp = angular.module('MyApp', ['ng', 'ngResource']);

MyApp.factory('flickrPhotos', function ($resource) {
    return $resource('http://api.flickr.com/services/feeds/photos_public.gne', { format: 'json', jsoncallback: 'JSON_CALLBACK' }, { 'load': { 'method': 'JSONP' } });
});

MyApp.directive('masonry', function ($parse) {
    return {
        restrict: 'AC',
        link: function (scope, elem, attrs) {
            elem.masonry({ itemSelector: '.masonry-item', columnWidth: $parse(attrs.masonry)(scope) });
        }
    };        
});

MyApp.directive('masonryItem', function () {
    return {
        restrict: 'AC',
        link: function (scope, elem, attrs) {
            elem.imagesLoaded(function () {
               elem.parents('.masonry').masonry('reload');
            });
        }
    };        
});

MyApp.controller('MasonryCtrl', function ($scope, flickrPhotos) {
    $scope.photos = flickrPhotos.load({ tags: 'dogs' });
});
<div class="masonry: 240;" ng-controller="MasonryCtrl">
    <div class="masonry-item" ng-repeat="item in photos.items">
        <img ng-src="{{ item.media.m }}" />
    </div>
</div>

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 9

var MyApp = angular.module('MyApp', ['ng', 'ngResource']);

MyApp.factory('flickrPhotos', function ($resource) {
    return $resource('http://api.flickr.com/services/feeds/photos_public.gne', { format: 'json', jsoncallback: 'JSON_CALLBACK' }, { 'load': { 'method': 'JSONP' } });
});

MyApp.directive('masonry', function ($parse) {
    return {
        restrict: 'AC',
        link: function (scope, elem, attrs) {
            elem.masonry({ itemSelector: '.masonry-item', columnWidth: $parse(attrs.masonry)(scope) });
        }
    };        
});

MyApp.directive('masonryItem', function () {
    return {
        restrict: 'AC',
        link: function (scope, elem, attrs) {
            elem.imagesLoaded(function () {
               elem.parents('.masonry').masonry('reload');
            });
        }
    };        
});

MyApp.controller('MasonryCtrl', function ($scope, flickrPhotos) {
    $scope.photos = flickrPhotos.load({ tags: 'dogs' });
});
<div class="masonry: 240;" ng-controller="MasonryCtrl">
    <div class="masonry-item" ng-repeat="item in photos.items">
        <img ng-src="{{ item.media.m }}" />
    </div>
</div>

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 9

var MyApp = angular.module('MyApp', ['ng', 'ngResource']);

MyApp.factory('flickrPhotos', function ($resource) {
    return $resource('http://api.flickr.com/services/feeds/photos_public.gne', { format: 'json', jsoncallback: 'JSON_CALLBACK' }, { 'load': { 'method': 'JSONP' } });
});

MyApp.directive('masonry', function ($parse) {
    return {
        restrict: 'AC',
        link: function (scope, elem, attrs) {
            elem.masonry({ itemSelector: '.masonry-item', columnWidth: $parse(attrs.masonry)(scope) });
        }
    };        
});

MyApp.directive('masonryItem', function () {
    return {
        restrict: 'AC',
        link: function (scope, elem, attrs) {
            elem.imagesLoaded(function () {
               elem.parents('.masonry').masonry('reload');
            });
        }
    };        
});

MyApp.controller('MasonryCtrl', function ($scope, flickrPhotos) {
    $scope.photos = flickrPhotos.load({ tags: 'dogs' });
});
<div class="masonry: 240;" ng-controller="MasonryCtrl">
    <div class="masonry-item" ng-repeat="item in photos.items">
        <img ng-src="{{ item.media.m }}" />
    </div>
</div>

javascript - How to enable CORS in AngularJs - Stack Overflow

javascript angularjs cors angularjs-http
Rectangle 27 2

Your problem is related with the fact that 'Access-Control-Allow-Origin': '*' needs to be set at the server. By doing this you enable CORS (Cross-Origin Resource Sharing)

Browsers have a security policy that prevents your javascript code to make requests from services that are not within your domain. For example if your javascript code is executed in http://example.com and the service you are targeting is found at http://example.com/api/myservice then your request will go through normally. If however, the service you are trying to access is at http://someotherdomain.net then the browser will not complete your request successfully even if the server responds normally.

You will have to read documentation about whatever web server software you're using on how to set headers on it. When you set 'Access-Control-Allow-Origin': '*' on your server your are essentially saying to the world - "You can load my data onto any browser application that lives in any domain". This means anyone in the world can call your service and if you wish to prevent this, you will have to implement authentication (common for this are API key models).

javascript - I get "No 'Access-Control-Allow-Origin' header error " ev...

javascript angularjs http-headers xmlhttprequest
Rectangle 27 2

Your problem is related with the fact that 'Access-Control-Allow-Origin': '*' needs to be set at the server. By doing this you enable CORS (Cross-Origin Resource Sharing)

Browsers have a security policy that prevents your javascript code to make requests from services that are not within your domain. For example if your javascript code is executed in http://example.com and the service you are targeting is found at http://example.com/api/myservice then your request will go through normally. If however, the service you are trying to access is at http://someotherdomain.net then the browser will not complete your request successfully even if the server responds normally.

You will have to read documentation about whatever web server software you're using on how to set headers on it. When you set 'Access-Control-Allow-Origin': '*' on your server your are essentially saying to the world - "You can load my data onto any browser application that lives in any domain". This means anyone in the world can call your service and if you wish to prevent this, you will have to implement authentication (common for this are API key models).

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

javascript - I get "No 'Access-Control-Allow-Origin' header error " ev...

javascript angularjs http-headers xmlhttprequest
Rectangle 27 1

This means that your http://thirdparty.url.com/ Does not accept requests from external sources that is/are not from http://thirdparty.url.com/, so you have to enable it from your thirdparty.url.com

This is true but I doubt if it offers a solution in every case (imagine we don't have permission to access the header of third party manually) as the headers can be modified from the browser to make a CORS request. Posted my answer below.

That won't help once it's deployed. You won't expect normal users to do that

javascript - AngularJS No 'Access-Control-Allow-Origin' header - Stack...

javascript angularjs cors
Rectangle 27 1

This means that your http://thirdparty.url.com/ Does not accept requests from external sources that is/are not from http://thirdparty.url.com/, so you have to enable it from your thirdparty.url.com

This is true but I doubt if it offers a solution in every case (imagine we don't have permission to access the header of third party manually) as the headers can be modified from the browser to make a CORS request. Posted my answer below.

That won't help once it's deployed. You won't expect normal users to do that

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

javascript - AngularJS No 'Access-Control-Allow-Origin' header - Stack...

javascript angularjs cors
Rectangle 27 1

This means that your http://thirdparty.url.com/ Does not accept requests from external sources that is/are not from http://thirdparty.url.com/, so you have to enable it from your thirdparty.url.com

This is true but I doubt if it offers a solution in every case (imagine we don't have permission to access the header of third party manually) as the headers can be modified from the browser to make a CORS request. Posted my answer below.

That won't help once it's deployed. You won't expect normal users to do that

javascript - AngularJS No 'Access-Control-Allow-Origin' header - Stack...

javascript angularjs cors
Rectangle 27 1

You could enable html5 pushstate and get rid of the # in your routes. You can do so by adding this to your .config

However, be aware that now there will not be a distinction between Angular routes vs. server requests. You'll have to config your server to deliver the appropriate static html file (e.g. index.html) for that url.

javascript - Is it possible to have traditional anchor links in Angula...

javascript angularjs anchor
Rectangle 27 1

You could enable html5 pushstate and get rid of the # in your routes. You can do so by adding this to your .config

However, be aware that now there will not be a distinction between Angular routes vs. server requests. You'll have to config your server to deliver the appropriate static html file (e.g. index.html) for that url.

javascript - Is it possible to have traditional anchor links in Angula...

javascript angularjs anchor