2016-11-22 75 views
0

在我的角码删除HTTP:从URL //本地主机前缀

app.directive("myDom", function ($compile) { 
var url = "\'https://examples.form.io/simple\'"; 
return { 
    link: function (scope, element) {   
     var template = '<formio src="' +url+ '"></formio><button>ClickMe</button>'; 
     var linkFn = $compile(template); 
     var content = linkFn(scope); 
     element.append(content); 
    } 
} 
}); 

我的显示为

http://localhost/'https://examples.form.io/simple' 

如何删除前缀http://localhost

看网址以下问题的答案但它没有帮助

Why is my JS putting a prefix to my links (localhost:3000/mylink)?

Removing http:// prefix from ASP loaded URL

+0

好吧,你能告诉我你需要什么,而不是你不想要什么?我帮助你会更容易。 – trichetriche

+0

最终模板应该是这样的

回答

1

别的东西必须要怎么回事,因为我只是把你的代码,并把它放在一个小提琴,并以其优良的工作:Fiddle。还有其他事情要做。

+0

但我的form.io src需要单引号 –

+0

您可以看到url:http: //localhost//'https://examples.form.io/simple'。你引用了哪些文件,使你相信需要报价?你在你的模板中双引号。 – Nix

+0

https://help.form.io/developer/info/#formio-directive –

-1

我在您的评论中看到了您的答案。

既然你知道,这两个给出需要的字符串,为什么不

var template = '<formio src="' + url.replace('http://localhost/', '') + '"></formio><button>ClickMe</button>';