摆弄相关代码:http: //jsfiddle.net/gFCzV/7/
我正在尝试设置下拉列表的选定值,该下拉列表绑定到ng-repeat中引用的对象的子集合.我不知道如何设置所选的选项,因为我无法以任何我所知道的方式引用它所绑定的集合.
HTML:
<div ng-app="myApp" ng-controller="SomeController">
<div ng-repeat="Person in People">
<div class="listheader">{{Person.firstName}} {{Person.lastName}}</div>
<div class="listitem" ng-repeat="Choice in Person.Choices">
{{Choice.Name}}:
<select
ng-model="Choice.SelectedOption"
ng-options="choice.Name for choice in Choice.Options"></select>
{{Choice.SelectedOption.ID}}
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
var myApp = angular.module('myApp', []);
myApp.controller("SomeController", function($scope) {
$scope.People = [{
"firstName": "John",
"lastName": "Doe",
"Choices": [
{
"Name":"Dinner",
"Options":[{Name:"Fish",ID:1}, {Name:"Chicken",ID:2}, {Name:"Beef",ID:3}],
"SelectedOption":{Name:"Chicken",ID:2} //this doesn't work
},
{
"Name":"Lunch",
"Options":[{Name:"Macaroni",ID:1}, {Name:"PB&J",ID:2}, {Name:"Fish",ID:3}],
"SelectedOption":""
}
],
}, {
"firstName": "Jane",
"lastName": "Doe"
}];
});
Run Code Online (Sandbox Code Playgroud)
这是我应该在模型上使用带有SelectedIndex的ng-init的一种情况吗?
上下文是Chrome 37.0.2062.120 m.
我正在使用execCommand将html插入到可编辑的div中.我的execCommand调用如下所示:
function insertHTML(){
document.execCommand('insertHTML', false, '<span id="myId">hi</span>');
}
Run Code Online (Sandbox Code Playgroud)
当可编辑的div看起来像这样:
<div contenteditable="true">
some [insertion point] content
</div>
Run Code Online (Sandbox Code Playgroud)
我使用execCommand将html插入一个contenteditable div,HTML的所有属性都按预期插入,我最终得到这个:
<div contenteditable="true">
some <span id="myId">hi</span> content
</div>
Run Code Online (Sandbox Code Playgroud)
但是,当我在此结构中插入完全相同的html时:
<div contenteditable="true">
some content
<div>more [insertion point] content</div>
</div>
Run Code Online (Sandbox Code Playgroud)
从插入的跨度中删除属性,它最终看起来像这样:
<div contenteditable="true">
some content
<div>more <span style="font-size: 10pt;">hi</span> content</div>
</div>
Run Code Online (Sandbox Code Playgroud)
有没有办法防止这种情况发生?
http://plnkr.co/edit/Rf0VItthVBg6j0z7KudO
我正在使用jQuery对话框并希望使用对话框按钮,但我不知道如何使用更新的模型触发范围以触发(当前不存在的)$ http或$ resource回调到服务器单击jQuery对话框按钮时.我觉得我好像错了,但我不知道要去哪里.
我正在尝试通过Postman使用Firebase Cloud Messaging发送测试通知。我正在对此网址进行POST
https://fcm.googleapis.com/v1/projects/[my project name]/messages:send
Run Code Online (Sandbox Code Playgroud)
邮递员中的“授权”选项卡设置为“无身份验证”,“我的标题”选项卡如下所示
Content-Type: application/json
Authorization: Bearer [server key]
Run Code Online (Sandbox Code Playgroud)
[服务器密钥]是Firebase项目“设置”区域中“云消息”标签中的新生成的服务器密钥。我不断收到此错误作为回应。
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
Run Code Online (Sandbox Code Playgroud)
根据我能找到的所有信息,我使用了正确的令牌,但Google似乎不同意。我应该发送什么作为Authorization标头来克服此错误?
我已经尝试了两种方法连接到我们正在运行的TFS服务器的workitemstore.尝试A是连接到配置服务器和使用GetService<WorkItemStore>()
方法.这总是返回null.
尝试B是连接到TfsTeamProjectCollection并使用该GetService<WorkItemStore>()
方法或将项目集合传递给WorkItemStore构造函数.在尝试B时,我得到一个异常,说明"从调用COM组件返回错误HRESULT E_FAIL".我可以在其上找到的唯一信息似乎表明存在一些权限问题,但我已经确认我已经通过身份验证作为具有对整个项目集合的读取权限的用户,并且我通过VS 2011开发预览进行了适当的连接和插入.
这是我如何连接......
public TfsConfigurationServer GetConfigurationServer()
{
Uri tfsUri = new Uri(configs.TfsUri);
TfsConfigurationServer server = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri, credProvider);
server.Authenticate();
if (server.HasAuthenticated == false)
throw new InvalidOperationException("You can't authenticate against the tfs instance.");
return server;
}
public TfsTeamProjectCollection GetProjectCollectionInstance(string projectCollectionName)
{
Uri tfsUri = new Uri(configs.TfsUri + "/" + projectCollectionName);
TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri, credProvider);
collection.Authenticate();
if (collection.HasAuthenticated == false)
throw new InvalidOperationException("You can't authenticate against the tfs instance.");
return collection;
}
Run Code Online (Sandbox Code Playgroud)
这就是我如何尝试获取WorkItemStore(愚蠢的代码来说明问题)...
public WorkItemProvider()
{ …
Run Code Online (Sandbox Code Playgroud) 即使提出这个问题,我也想知道如此简单的事情对我来说如此困难.我想要做的就是按计划自动停止和启动Azure WebSite.起初,我查看了WebJobs,并创建了一个powershell脚本,可以阻止使用stop-azurewebsite命令行开关的WebSite:
stop-azurewebsite [my site]
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个.cmd文件,使用powershell.exe来调用它来执行powershell文件
PowerShell.exe -ExecutionPolicy RemoteSigned -File stopit.ps1
Run Code Online (Sandbox Code Playgroud)
我创建了一个WebJob来运行powershell命令来停止该站点,但它错误地显示了一条消息:
stop-azurewebsite : The term 'stop-azurewebsite' is not recognized as the name
of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try
again.
Run Code Online (Sandbox Code Playgroud)
所以,我想我会去REST API路线.我使用fiddler创建了一个post请求,并使用适当的管理证书来调用:
https://management.core.windows.net/[my subscription id]/services/WebSpaces/[webspace]/sites/[website name]/stop
Run Code Online (Sandbox Code Playgroud)
事实证明,没有'停止'命令.有'重启',但在这种情况下显然没有用.所以,所有的说,什么是在一个特定的时间安排自动执行Azure的网站停止和随后的(但要晚得多),启动时有一个合理的方式?
更新:
我已经弄清楚如何使用PUT发出http请求来停止网站
https://management.core.windows.net/[my subscription id]/services/WebSpaces/[webspace]/sites/[website name]
有一个机构{"State":"Stopped"}
,但我仍然没有一个明显的方式在WebJob中对此URL进行"PUT".
我正在将PUT请求中的json有效负载发送到Web API控制器操作.有问题的行为有一个如下所示的签名:
public IHttpActionResult Post([FromBody]SaveThingRequest request)
Run Code Online (Sandbox Code Playgroud)
SaveThingRequest看起来像这样:
public class SaveThingRequest
{
public List<ElementInfo> Elements { get; set; }
public class ElementInfo
{
public List<ElementSettingInfo> Settings { get; set; }
public class ElementSettingInfo
{
public string Name { get; set; }
public string Value { get; set; }
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在包含具有设置的元素的请求正文中发布了json.我通过在控制器操作中手动反序列化并确认JSON具有类似于以下内容的结构来证实这一点:
{
Elements: [
{
Settings: [
{
Name: 'Name 1',
Value: 'Value 1'
},
{
Name: 'Name 2',
Value: 'Value 2'
}
]
},
{
Settings: [
{
Name: …
Run Code Online (Sandbox Code Playgroud) 这是一个工具问题,所以我不确定它是否适合堆栈溢出.我在WebStorm 10中使用gulp将我的.js文件连接到dist文件夹中.在我的gulpfile.js中,WebStorm警告我gulp.src(...).pipe()
无法解决.
我已经将gulp-util typescript社区映射文件添加到了设置中的库列表中,这是pipe()
我可以在node_modules中找到的唯一存在的函数.
我还确认gulp-util库正在尝试解析gulpfile.js中的引用.这是我在我的应用程序中留下的唯一警告,我很乐意将其解决.
相关的小提琴:https: //jsfiddle.net/tqf4zea7/1/
我在角度控制器中使用$ q.为了测试某些场景,我在作用域上创建了一个数组,用于将消息推送到:
$scope.messages = [];
Run Code Online (Sandbox Code Playgroud)
我已经设置了一个返回$ q函数的函数,如下所示:
function returnAPromise(valToReturn){
return $q(function(resolve, reject){
$timeout(function(){
resolve(valToReturn);
}, 500);
});
}
Run Code Online (Sandbox Code Playgroud)
然后我.then()
调用结果看起来像这样:
returnAPromise('third').then($scope.messages.push);
Run Code Online (Sandbox Code Playgroud)
因为我只想将promise的解析值推送到数组,我想我可以传递messages数组的push方法,但是当我这样做时,我收到以下错误:
VM289 angular.js:12520 TypeError: Array.prototype.push called on null or undefined
at processQueue (VM289 angular.js:14792)
at VM289 angular.js:14808
at Scope.$eval (VM289 angular.js:16052)
at Scope.$digest (VM289 angular.js:15870)
at Scope.$apply (VM289 angular.js:16160)
at VM289 angular.js:17927
at completeOutstandingRequest (VM289 angular.js:5552)
at VM289 angular.js:5829
Run Code Online (Sandbox Code Playgroud)
如果我将push包含在函数中,它可以正常工作:
returnAPromise('third').then(function(message){
$scope.messages.push(message)
});
Run Code Online (Sandbox Code Playgroud)
这是一个我不明白的封闭问题吗?
我正在进行Firebase部署,但是我的本地文件与我提供的文件不匹配。我已经检查了已部署目录中的文件,已禁用高速缓存,已硬加载,已直接导航到该文件,已对该文件进行了其他更改,已从本地部署dev机器和干净的CI服务器。
我导航到http://localhost:3000/views/tasks.html
一个HTML结果,然后https://[my-firebase-url]/views/tasks.html
查看同一文件的旧HTML结果。
我已经完成firebase deploy --debug
,一切都报告为成功,并且文件计数正确。我还能找到其他信息吗?有没有办法查看调试文件中提到的上传到firebase的构建?
到现在为止,每次使用相同的项目和文件结构都可以使用此功能。解决此问题的任何方法都很棒。谢谢!
angularjs ×3
javascript ×2
azure ×1
execcommand ×1
firebase ×1
gulp ×1
json ×1
ng-options ×1
tfs ×1
tfs-workitem ×1
tfs2010 ×1
webstorm ×1