我正在学习AngularJS并且已经设置了项目的结构,但是当我调用返回JSON的API时,我无法在html中显示它.
您的想法是单击按钮,返回的结果将显示在{{answer}}中.
HTML:
<div ng-app="xileapp">
<div ng-controller="searchController">
<input type="button" ng-click="search()" value="search" />
<div>Answer: {{answer}}</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
控制器:
xile.controller('searchController', ['personSearch', '$scope', function (personSearch, $scope) {
$scope.search = function () {
$scope.answer = personSearch.findPlayer();
}
}]);
Run Code Online (Sandbox Code Playgroud)
服务:
xile.service('personSearch', function ($http) {
this.findPlayer = function() {
$http({
method: 'GET',
url: 'https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/Crucify?api_key=222015c4-0898-4f6b-a7d5-2a23c3e0344d'
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
return response;
}, function errorCallback(response) {
// called asynchronously if an error occurs
// …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现一个正则表达式,它将检查字符串是否介于1到50个字符之间.他们可以输入任何字符.
我是创建正则表达式的新手,但这是我的尝试: ^{1,50}$
我试过的原因是我发现这是限制角色的方法.
对此的任何帮助都会很棒.
我目前遇到的问题是,在“IsFocused”属性上,我能够触发文本框的背景更改,但是当我想更改 BorderBrush 时它不起作用。
<TextBox Padding="2" FontFamily="Sans Serif" Foreground="Red" FontSize="10px" FontWeight="Medium" Width="200" BorderThickness="2" VerticalAlignment="Center">
<TextBox.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="2"/>
</Style>
</TextBox.Resources>
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="BorderBrush" Value="#858585"/>
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
Run Code Online (Sandbox Code Playgroud)
谁能看出这行不通的原因?
我刚刚发现当我“右键单击”时它会变成红色?当用户单击文本框时,我希望它变为红色。
我有一个功能,让用户在执行此操作时编辑图像我将这个新图像保存到我保存到数据库等的文件中...
问题来自于当我尝试查找我刚刚保存的文件时它说它不存在但它确实存在?
这里我将新文件保存到TEMP文件夹:
string newFullTempFolderURL = Path.Combine(Global.TempFolder, newFullFileName + ".png");
_image.Save(newFullTempFolderURL, System.Drawing.Imaging.ImageFormat.Png);
Run Code Online (Sandbox Code Playgroud)
此时,当我检查文件夹时,文件位于包含新图像的文件夹中.
然后,当我继续将文件上传到服务器(使用BITS)时,我会检查以确保文件存在:
if (File.Exists(Path.Combine(Global.TempFolder + "\\" + newFullFileName)))
{
}
Run Code Online (Sandbox Code Playgroud)
当我可以亲眼看到文件时,这会返回false(不存在)!
有人有同样的问题吗?
EDIT1:
newFullFileName已包含.png:
string newFullFileName = string.Format(oldFileName.Substring(0, oldFileName.IndexOf("_") + 1) + DateTime.Now.ToString(), "yyyyMMddhhmmss").Replace(@"/", "").Replace(" ", "").Replace(":", "") + ".png";
Run Code Online (Sandbox Code Playgroud) 我有一个Listbox,它有一个ItemSource绑定到后面的代码中的属性.
<Border BorderBrush="#d6786a" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="2" Grid.Column="15" Grid.Row="5" Grid.ColumnSpan="3">
<ListBox x:Name="ListSrc" Background="#ececec" ItemsSource="{Binding Path=ListBoxData}" dd:DragDrop.IsDragSource="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="Transparent" BorderThickness="0">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4" Margin="15"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
</ListBox.Resources>
</ListBox>
</Border>
Run Code Online (Sandbox Code Playgroud)
从下图中可以看出,项目直接在彼此上方/下方.我怎么能在行之间添加一些填充?