在我的一个角度应用程序中,当我在ng-repeat中传递键时,我将得到值.
这里,每个排在rowsdata具有类似值'my file1 data', 'my file2 data', 'my file3 data'
但我需要传递它 'myfile1data', 'myfile2data', 'myfile3data'
当我使用rows.replace('','')时,它只删除第一个空格 'myfile1 data', 'myfile2 data', 'myfile3 data'
<tr ng-repeat="data in datas">
<td ng-repeat="rows in rowdatas">{{data[rows.replace(' ','')]}}</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
编辑
但是当我使用时
<td ng-repeat="rows in rowdatas">{{data[rows.replace(/ /g,'')]}}</td>
Run Code Online (Sandbox Code Playgroud)
我有
Error: a is not a function OPERATORS["/"]@http://loclhost/jcp_standardwork/secure/scripts/vendor/angular/a??ngular.js:5959 OPERATORS["/"]@http://loclhost/jcp_standardwork/secure/scripts/vendor/angular/a??ngular.js:5959 binaryFn/<@http://loclhost/jcp_standardwork/secure/scripts/vendor/angular/angul??ar.js:6292
Run Code Online (Sandbox Code Playgroud)
有人能告诉我一些解决方案吗?
我有 var recommend = 'I recommended Garden Solutions for this Tender Contracting on the basis of\n\n1)Top Scorer for tender\n2)Professional Experience in Building Services\n3)Approved Service Providers';
我想\n用HTML中断替换,并希望显示如下:
我在此基础上推荐了Garden Solutions for this Tender Contracting
1)投标的最佳得分手
2)建筑服务的专业经验
3)经批准的服务提供商
我正在使用JavaScript的替换功能
var val = recommend.replace("\n","<br>");
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
这是一个简单的replace()问题 - 我无法让它在下面的函数中替换子字符串.
function linkOnClick(){
var anyNameYouLike = 'some sort of text/string right here';
anyNameYouLike.replace('right','in');
alert(anyNameYouLike)
}
Run Code Online (Sandbox Code Playgroud)
它应该返回"这里的某种文本/字符串",但不是.我究竟做错了什么?我对Javascript很新(如果不明显......)
如何find在正则表达式中包含变量?
var find = 'de';
var phrase = 'abcdefgh';
var replace = '45';
var newString = phrase.replace(/de/g, replace)
Run Code Online (Sandbox Code Playgroud)
即:var newString = phrase.replace(/ find/ g,replace)
预期: phrase = 'abc45fgh';
我正在尝试替换同一个div.
显然这行不通,这是我的代码。
$("#Number").each(function() {
var text = $(this).text();
$(this).text(text.replace("Monster", "Witch"));
});
$("#Number").each(function() {
var text = $(this).text();
$(this).text(text.replace("Girl", "Boy"));
});
Run Code Online (Sandbox Code Playgroud)
谢谢你。
我正在尝试用JavaScript替换'$$$'.就那么简单.
我有以下代码:
var splitSign = '$$$';
var string = 'hello$$$how$$$are$$$you';
var regex = new RegExp(splitSign,'g');
var res = string.replace(regex,' ');
console.info(res);
Run Code Online (Sandbox Code Playgroud)
结果是字符串没有被修改!任何想法为什么?
我想创建带有 url 的页面,例如:
http://xyzcorp/schedules/2015Aug24_Aug28/Jim_Hawkins
http://xyzcorp/schedules/2015Aug24_Aug28/Billy_Bones
http://xyzcorp/schedules/2015Aug24_Aug28/John_Silver
Run Code Online (Sandbox Code Playgroud)
这些特定的 URL 将全部包含完全相同的内容(“2015Aug24_Aug28”页面),但会突出显示最后标记的名称的所有实例。例如,“ http://xyzcorp/schedules/2015Aug24_Aug28/Billy_Bones”将突出显示名称“Billy Bones”的每个实例,就好像通过浏览器在页面上执行了该名称的“查找”操作一样。
我想客户端需要这样的东西:
var employee = getLastURLPortion(); // return "Billy_Bones" (or whatever)
employee = humanifyTheName(employee); // replaces underscores with spaces, so that it's "Billy Bones" (etc.)
Highlight(employee); // this I have no clue how to do
Run Code Online (Sandbox Code Playgroud)
这可以在 HTML/CSS 中完成吗?或者是否还需要 JavaScript 或 jQuery?
我想删除字符串中间的空格,$.trim()例如:
console.log($.trim("hello, how are you? "));
Run Code Online (Sandbox Code Playgroud)
我明白了:
hello, how are you?
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到
hello, how are you?
Run Code Online (Sandbox Code Playgroud)
谢谢.
Object.prototype.getB = function() {
// how to get the current value a
return a.b;
};
const a = {b: 'c'};
a.getB();
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我想为所有对象值创建一个函数。我需要获取这个函数中的对象值然后做一些事情。
我在这里有一串文本,它将被动态生成为以下之一:
<h1 id="headline">"Get your FREE toothbrush!"</h1>
OR
<h1 id="headline">"FREE floss set and dentures!"</h1>
Run Code Online (Sandbox Code Playgroud)
由于这将是动态生成的,我将无法在<span>“FREE”这个词周围用 a 包裹,所以我想使用 Javascript 专门针对“FREE”这个词,以便我可以使用不同的字体系列和字体颜色来设置它的样式比任何样式<h1>设置。我用什么方法来做这件事?