我正在尝试window.open使用带空格的网址:
var msg = 'Hello, world!';
var url = 'http://yoursite.com';
var link = 'http://www.twitter.com/share?text=' + msg + '&url=' + url;
window.open(link);
Run Code Online (Sandbox Code Playgroud)
运行此代码将打开一个新窗口http://twitter.com/share?text=Hello,%2520world!&url=http://yoursite.com.
会发生什么是msg中的空格转换为%20,然后'%'转换为%25.作为一种解决方法,我补充说:
msg = msg.replace(/\s/g, '+');
但是我需要注意其他字符还是有更好的解决方法?
其他网站的推荐程序生成带有哈希码的url来表示引用者.当网址发送给朋友和家人时,某些点或识别系统会奖励由哈希码定义的引用者...但为什么哈希码?为什么不是用户ID?
angularFire $ bind方法可以在这里找到:http://angularfire.com/flatdoc.html 和最新的ng-grid可以在这里找到:http://angular-ui.github.io/ng-grid/
我尝试了最简单的解决方案,但它没有用:
$scope.myData = [{name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: 29},
{name: "Enos", age: 34}];
$scope.gridOptions = {
data: 'myData',
rowTemplate:'<div ng-style="{\'cursor\': row.cursor, \'z-index\': col.zIndex(), \'color\': \'rgb(248, 248, 248)\',\'background\': \'none repeat scroll 0% 0% rgba(51, 51, 51, 0.7)\' }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell {{col.cellClass}}" ng-cell></div>',
headerRowTemplate: '<div ng-style="{ height: col.headerRowHeight,\'color\': \'rgb(248, 248, 248)\',\'background\': \'none repeat scroll 0% 0% rgba(51, 51, 51, 0.7)\' …Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试通过一个元素添加一个类ng-class.如您所见,代码非常简单但不添加类:
app.run(function($rootScope, $location,$http,ngDialog,array_helper){
var update = function() {
/*CONFIG PARAMS*/
$rootScope.config = {};
$rootScope.config.app_routes = [
"/",
"/channels",
"/channels/create",
"/users",
"/auth/login",
"/auth/signup"
];
console.log($rootScope.config.app_url);
console.log($rootScope.config.app_routes.indexOf($rootScope.config.app_url));
};
$rootScope.$on('$routeChangeStart', function() {
update();
});
});
Run Code Online (Sandbox Code Playgroud)
然后在视图中,我做:
<div ng-view ng-animate class="" ng-class="{'slide': config.app_routes.indexOf(config.app_url) == -1}"></div>
Run Code Online (Sandbox Code Playgroud)
但似乎它永远不会起作用,因为它永远不会增加课程slide.同时console.log效果很好,只有在正确时才返回-1:O
跟进PHP正则表达式以将字母数字字符串与某些(但不是全部)标点符号匹配,我必须接受至少2种类型的字符,这些字符必须是数字,字母或标点之一,而字符串必须介于长度为6和18个字符。这是最好的方法吗?我使用RegExLib的模式构造了此正则表达式。
preg_match('@' .
// one number and one letter
'^(?=.*\d)(?=.*[a-zA-Z])[!-%\'-?A-~]{6,18}$' .
// one number and one punctuation
'|^(?=.*\d)(?=.*[!-%\'-/:-?\[-`{-~])[!-%\'-?A-~]{6,18}$' .
// or one punctation and one
'|^(?=.*[!-%\'-/:-?\[-`{-~])(?=.*[a-zA-Z])[!-%\'-?A-~]{6,18}$' .
'@i', $pass, $matches);
Run Code Online (Sandbox Code Playgroud) 在以下case语句中,x被设置为#\ j,但返回"bye".
(case (find #\j "joy") ((x) (princ "hi")) (otherwise (princ "bye")))
Run Code Online (Sandbox Code Playgroud)
find应该返回#\ j,它应该匹配x,对吧?
javascript ×3
angularjs ×2
angularfire ×1
arrays ×1
common-lisp ×1
drupal ×1
escaping ×1
firebase ×1
ng-class ×1
ng-grid ×1
php ×1
referrals ×1
regex ×1
spaces ×1
view ×1
window.open ×1