Topic: AngularJS

Remove Hashtag From URL in AngularJS 0

Remove Hashtag From URL in AngularJS

Remove Hashtag From URL in AngularJS

Today, We want to share with you Remove Hashtag From URL in AngularJS.
In this post we will show you Pretty URLs in AngularJS: Removing the #, hear for Removing Hashbang from URL in AngularJs Route we will give you demo and example for implement.
In this post, we will learn about Removing “#” From URL in AngularJS with an example.

How to remove # from URL in AngularJS?

If you work on AngularJS any SPA’s or web application using angular multiple pages or route then you notice most useful one thing. If you check any link click on any hyper links it creates like as bellow simple generated URI:

http://live24u.com/#
http://live24u.com/#/students
http://live24u.com/#/teachers

We stands always put “#” symbols will be add there, So when we live this any application or web application then it should remove or delete “#” Special Symbols from Your Angular Routing URL, because it creates issue when we some share link on Social media facebook, Twitter, Linkdin or etc.

http://live24u.com/
http://live24u.com/students
http://live24u.com/teachers

Enabling Base URL (Relative URLs)

<base href="/YOUR_FOLDER_NAME/Index/">   

If We are using Latest New version of an Angularjs, then We can simple directly write this Scripts to enable Your html5mode.

$locationProvider.html5Mode(true);   

But You can delete or remove simple Way to easily using angular “$locationProvider.html5Mode(true);”. You can do it like as bellow simple example We did, So Create sure you have to simple first add HTML base tag on your HTML head tag sections like as bellow scripts:

<head>
	<base href="/"> 
	....
	//Some Title
	//External Links...
	//Devloped By : Pakainfo.com
</head>

Simple Angular JS Route

var liveapp =  angular.module('live-App',['ngRoute']);
liveapp.config(['$routeProvider','$locationProvider',
    function($routeProvider, $locationProvider) {
        $routeProvider.
            when('/', {
                templateUrl: 'templates/students.html',
                controller: 'StudentCtrl'
            }).
            when('/teachers', {
                templateUrl: 'templates/teachers.html',
                controller: 'TeacherCtrl'
            }).
              otherwise({
                redirectTo: '/'
            });

	//It's Most Imp.
    $locationProvider.html5Mode(true);
}]);

Remove # from URL AngularJS : Conclusion

This is the Very Useful way to Delete or remove Hash From Application URL and get a SEO based pretty URL.

We hope you get an idea about Remove Hashtag From The Routing URL – $locationProvider
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like Face Book Page.

We hope This Post can help you…….Good Luck!.

No Access-Control-Allow-Origin header 0

No Access-Control-Allow-Origin header

No Access-Control-Allow-Origin header

Today, We want to share with you No Access-Control-Allow-Origin header.
In this post we will show you How to solve – No ‘Access-Control-Allow-Origin’, hear for How to fix Access-Control-Allow-Origin (CORS origin) we will give you demo and example for implement.
In this post, we will learn about ERROR : No “Access-Control-Allow-Origin” header is present with an example.

Error: “No Access-Control-Allow-Origin header” is some data present on the data requested main resource.

How to solve – No ‘Access-Control-Allow-Origin’ – Syntax

The simple used in server side Access-Control-Allow-Origin some response Data header indicates some results whether the data response can be more shared with data resources with the given PHP, .net, webapi, C#, etc. origin.

Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: <origin>

PHP SET- Access-Control-Allow-Origin

<?php header('Access-Control-Allow-Origin: *'); ?>

If you are using Latest , For used to:

app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});

For c# web services – webapi

Please put the following source code in your App web.config simple file under C# tag tag.

<httpProtocol>
    <studentHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
    </studentHeaders>
</httpProtocol>

Please create sure you are not any access doing any some mistake in the jquery ajax call

jQuery

$.ajax({
    url: 'http://live24u.com/api/mycall',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    }, 
    type: "POST", /* methods or type:"GET" methods or type:"PUT" methods */
    dataType: "json", //dataType
    data: {
    },
    success: function (data) {
        console.log(data);    
    },
    error: function () {
        console.log("error");
    }
});

Mixed Content: The page was not data loaded over HTTPS. This some request has been blocked.

In some order to fix an issue for your WordPress website or ay blog, just put simple below source code into your root .htaccess file.

.htaccess

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

As you Display Access-Control-Allow-Origin “*” some allows you to all the file access all folder and files resources and webfonts from all this domains.

We hope you get an idea about No ‘Access-Control-Allow-Origin’ solve this error header is present
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

AngularJS – update bind ng-model input value from Jquery Code 0

AngularJS - update bind ng-model input value from Jquery Code

AngularJS – update bind ng-model input value from Jquery Code

Today, We want to share with you AngularJS – update bind ng-model input value from Jquery Code.
In this post we will show you Read and Set Input Value using AngularJS, hear for AngularJS – update bind ng-model input value from Jquery Code we will give you demo and example for implement.
In this post, we will learn about How to get HTML form input value in AngularJs controller with an example.

Irregularly, we include to set text value of HTML input box from js source code, however
if you some data bind with ng-model of angular then you can not text input set value here directly with set “val()” of jquery. As simple Bellow example:

$("#your-name").val('live24u');

however of you input value set this way and then it will see in your HTML text box, however
you can not get HTML from on submit methods. Therefor, you have to also click ot trigger HTML input type Box that way more easy to AngularJS can get on angular controller function.

You can display bellow full source code example that way you can best way to step by step understand how to solve angularjs update bind ng-model input value from Jquery Code:

Example:

<!DOCTYPE html>
<html>
<head>
    <title>AngularJS - update bind ng-model input value from Jquery Code</title>
	<!-- jquery.min.js -->
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
	<!-- Devloped by angular.min.js -->
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>

<h2>AngularJS - update bind ng-model input value from Jquery source Code</h2>
<div ng-app="liveApp" ng-controller="liveCtrl" id="mainController">
	<form name="form" ng-submit="myliveform()">
	 <input type="text" ng-model="form.name" placeholder="Enter Your Name" id="your-name" />
		 <button type="button" class="defult-change">Change Value</button>
		 <button type="submit">Submit</button>
	</form>
</div>

<script type="text/javascript">
 var liveApp = angular.module("liveApp", []);
 liveApp.controller('liveCtrl', function($scope, $timeout) {
	$scope.myliveform = function() {
		console.log($scope.form.name);
	}
 });
</script>

<script type="text/javascript">
	$('.defult-change').click(function(){
		var liveInput = $("#your-name");
		liveInput.val('live24u');
		liveInput.trigger('input');
	});
</script>

</body>
</html>

We hope you get an idea about How to get HTML form input value in AngularJs controller
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.