我对正则表达式很糟糕,但我想知道是否可以将ng-pattern与变量一起使用
例如,
ng-pattern="/^{{validationCode}}$/"
Run Code Online (Sandbox Code Playgroud)
其中validationCode是一个附加到控制器中$ scope的变量
// Inside Controller
$scope.validationCode = 'response returned from server'
Run Code Online (Sandbox Code Playgroud)
如果
$scope.validationCode = 1234123412351234
Run Code Online (Sandbox Code Playgroud)
那么ng-pattern就是
ng-pattern="/^1234123412351234$/"
Run Code Online (Sandbox Code Playgroud)
但这不起作用,似乎我需要创建一个我不想要的自定义指令
在menus.client.service.js文件中,我试图理解MEAN.js框架中菜单的填充结构
代码从分配给它的空菜单对象开始
this.menus = {}
Run Code Online (Sandbox Code Playgroud)
然后在文件的底部,调用this.addMenu('topbar')函数
// Add new menu object by menu id
this.addMenu = function(menuId, isPublic, roles) {
console.log('pre-this.menus')
console.log(this.menus) // empty object
// Create the new menu
this.menus[menuId] = {
isPublic: isPublic || false,
roles: roles || this.defaultRoles,
items: [],
shouldRender: shouldRender
};
console.log('post-this.menus')
console.log(this.menus[menuId]) //complete populated menu with submenus i.e "List Articles", "New Article"
// Return the menu object
return this.menus[menuId];
};
Run Code Online (Sandbox Code Playgroud)
通过这一个函数,似乎有两个其他函数被调用
this.addMenuItem和this.addsubMenuItem
但我不知道它是怎么发生的,因为我没有看到它们在文件中明确调用.
我想我在这里错过了一个重要的概念.我还查看了header.client.controller.js文件,但它只是调用getMenu函数并分配给$ scope.menu
$scope.menu = Menus.getMenu('topbar');
Run Code Online (Sandbox Code Playgroud)
这是完整的非功能性文件代码
jsfiddle:http://jsfiddle.net/4c5gc0aq/
我正在使用aws-sdk javascript我的后端,我可以使用AWS正常,但当我尝试使用该getOpenIdTokenForDeveloperIdentity方法时,我得到"Missing region in config error"一个响应.
var config = new AWS.Config({
accessKeyId: "MYACCESSKEY", secretAccessKey: "MYSECRETYKEY", region: 'us-east-1'
});
var params = {
IdentityPoolId: 'MYIDENTITYPOOLID', /* required */
Logins: { /* required */
"login.my.myapp": 'string',
/* anotherKey: ... */
},
IdentityId: null,
TokenDuration: 0
};
cognitoidentity.getOpenIdTokenForDeveloperIdentity(params,function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
Run Code Online (Sandbox Code Playgroud)
在文档中它说:
默认情况下,凭据和区域设置保持未配置状态.在使用任何AWS服务API之前,应由应用程序配置此项.
所以我设置了我的区域,但为什么我仍然收到错误?