Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace HTTP with a simple string in angular.js? [closed]

Tags:

angularjs

I am started to work with Angular.js, I want to replace HTTP:// of any URL in a simple string like 'hey', I didn't get any relevant solution. I'd be grateful for your response.

like image 373
abdulbarik Avatar asked Jul 05 '26 14:07

abdulbarik


2 Answers

try this. http://www.w3schools.com/jsref/jsref_replace.asp

var str = "Visit Microsoft!";
var res = str.replace("Microsoft", "W3Schools");
like image 180
Naeem Shaikh Avatar answered Jul 07 '26 04:07

Naeem Shaikh


I got my answer here is the controller code

function ListCtrl($scope, $http,Project) {
  $http.get('/project').success(function(data){
   for(var i=0;i<data.length;i++){
   data[i].site=data[i].site.replace('http://','Hey');

 }
  $scope.projects=data;
});
like image 42
abdulbarik Avatar answered Jul 07 '26 04:07

abdulbarik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!