我正在尝试使用'track by'表达式来跟踪对象数组中id的选择.但是,我似乎无法让它像我认为的那样有效.
//ids from server
$scope.serverDTO = ['1','2','3'];
//composed objects from the ID set
$scope.composedData = [{id:1,name:"test"},{id:2,name:"test"},{id:3,name:"test"}];
<!-- select box -->
<select ng-model="serverDTO" ng-options="item as item.name for item in composedData track by item.id"></select>
Run Code Online (Sandbox Code Playgroud)
因此,基于文档,我认为加载的选项指令会看到serverDTO具有1,2和3的'track by'id,并且具有预先选择的那些.用户修改选择后,我需要做这样的事情,将数组返回给服务器 -
//recreate proper DTO [1,2,3];
$scope.serverDTO = $scope.serverDTO.map(function(val){
return val.id;
});
Run Code Online (Sandbox Code Playgroud)
我是否应该如何工作呢?
我正在研究一个不可确定的可嵌套性的树视图,但是想为样式定义一些嵌套规则.例如,我希望第一级项目具有特定边框.紧接在下面的嵌套项目具有不同的边框.我有一个工作的例子,但它是静态和冗长的.我知道使用选择器必须有更好的方法,但我似乎无法使它工作.这是我目前的解决方案 -
.item {
border-left-color: #somecolor1;
}
.item > .item {
border-left-color: #somecolor2;
}
.item > .item > .item {
border-left-color: #somecolor3;
}
.item > .item > .item > .item {
border-left-color: #somecolor4;
}
.item > .item > .item > .item > .item {
border-left-color: #somecolor5;
}
Run Code Online (Sandbox Code Playgroud)
所以这有效,但显然它有点冗长.有没有更好的办法?
我试图弄清楚如何在生命周期的不同点将maven属性设置为不同的值.例如,如果我在项目级别设置属性
<project>
<properties>
<some.property>Value</some.property>
</properties>
</project>
Run Code Online (Sandbox Code Playgroud)
在第三方插件执行期间,我希望能够将其更改为其他内容.
<plugins>
<plugin>
<groupId>com.github.mcheely</groupId>
<artifactId>requirejs-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<!-- change the value here -->
</execution>
<execution>
<!-- change the value here again-->
</execution>
</executions>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
或者,不是去变量设置路径,如果我可以访问特定执行中的唯一ID或属性集,它也可以工作.例如-
<plugins>
<plugin>
<groupId>com.github.mcheely</groupId>
<artifactId>requirejs-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<id>SomeID</id>
<!-- change the value here -->
</execution>
<execution>
<id>SomeID</id>
<!-- change the value here again-->
</execution>
</executions>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
然后像这样访问这个变量
${execution.id}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我确信这个问题很容易解决,但我对iOS开发相对较新.我正在尝试将触摸事件传递给UIView上绘制顺序较低的子项.例如 -
我创建扩展的UIImageView来创建我的MoveableImage类.这个类基本上是UIImageView,它实现了touchesBegan,touchesEnded和touchesMoved-
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self showFrame];
//if multitouch dont move
if([[event allTouches]count] > 1)
{
return;
}
UITouch *touch = [[event touchesForView:self] anyObject ];
// Animate the first touch
CGPoint colorPoint = [touch locationInView:self];
CGPoint touchPoint = [touch locationInView:self.superview];
//if color is alpha of 0 , they are touching the frame and bubble to next responder
UIColor *color = [self colorOfPoint:colorPoint];
[color getRed:NULL green:NULL blue:NULL alpha:&touchBeganAlpha];
NSLog(@"alpha : %f",touchBeganAlpha);
if(touchBeganAlpha > 0)
{
[self animateFirstTouchAtPoint:touchPoint]; …Run Code Online (Sandbox Code Playgroud) 我在我的WebAPI应用程序中使用带有OAuth的OWIN中间件的asp.net身份提供程序.使用模板和
https://www.nuget.org/packages/Microsoft.AspNet.Identity.Samples
我在WebAPI端点上运行OAuth.但是,我没有看到如何扩展此体系结构以为不同的请求提供不同的令牌生存期.
例如,我的REST API将由Web应用程序和移动应用程序使用.我希望移动应用程序的令牌生命周期比Web应用程序长得多.
在我的Startup.Auth.cs文件中,我看到以下OAuth配置 -
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider<ApplicationUserManager, DirectoryUser, Guid>(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
});
Run Code Online (Sandbox Code Playgroud)
有没有办法在每个令牌请求中覆盖此行为?例如,我可以公开"/ Token" - > 14天和"/ DeviceToken" - > 60天.这可能吗?
我正在尝试使用我的IIS托管WebAPI 2.2应用程序设置集成测试.我使用Autofac进行DI,我使用的是使用OWIN的新ASP.net Identity堆栈.我遇到了Autofac的问题,其中HttpContext类总是为null.以下是我如何设置我的基本集成测试类 -
[TestClass]
public class TestBase
{
private SimpleLifetimeScopeProvider _scopeProvider;
private IDependencyResolver _originalResolver;
private HttpConfiguration _configuration;
public TestServer Server { get; private set; }
[TestInitialize]
public void Setup()
{
Server = TestServer.Create(app =>
{
//config webpai
_configuration = new HttpConfiguration();
WebApiConfig.Register(_configuration);
// Build the container.
var container = App_Start.IocConfig.RegisterDependencies(_configuration);
_scopeProvider = new SimpleLifetimeScopeProvider(container);
//set the mvc dep resolver
var mvcResolver = new AutofacDependencyResolver(container, _scopeProvider);
_originalResolver = DependencyResolver.Current;
DependencyResolver.SetResolver(mvcResolver);
//set the webapi dep resolvers
_configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
app.UseAutofacMiddleware(container); …Run Code Online (Sandbox Code Playgroud) asp.net integration-testing autofac asp.net-mvc-5 asp.net-web-api2
在我的具体案例中,我很难理解模式匹配; 我试图params在Phoenix控制器中获取值,我认为这是一个结构.
打字params中iex的结果
%{"edit" => "93213e66-a15e-11e6-8bc7-38c986312498",
"job_slug" => "7759-tkhkjd-test"}
Run Code Online (Sandbox Code Playgroud)
但是,运行以下命令:
pry(7)> {edit, job_slug} = params
Run Code Online (Sandbox Code Playgroud)
抛出此错误:
** (MatchError) no match of right hand side value: %{"edit" => "93213e66-a15e-11e6-8bc7-38c986312498", "job_slug" => "7759-tkhkjd-test"}
(stdlib) :erl_eval.expr/3
Run Code Online (Sandbox Code Playgroud)
如何正确模式匹配params?
asp.net ×2
angularjs ×1
autofac ×1
css ×1
elixir ×1
iphone ×1
javascript ×1
maven ×1
maven-3 ×1
maven-plugin ×1
ng-options ×1
oauth-2.0 ×1
objective-c ×1
owin ×1
touch ×1
uiimageview ×1
uiview ×1