在我的Angular应用程序中,我有一个md-tabs,其md-selected指令绑定到我的控制器中的属性.我想将当前选项卡更改为索引由我的模板中其他位置的ng-click调用的函数设置的选项卡.
我是这样做的:
<div ng-controller="TrackingCtrl" layout-fill>
<md-content ng-if="isSmart" layout-fill>
<md-tabs md-selected="selectedIndex" layout-fill>
<md-tab>.........</md-tab>
<md-tab>.........</md-tab>
<md-tab>.........</md-tab>
<md-tab>
<md-tab-label>{{ 'tracking.positions.TITLE' | translate }}</md-tab-label>
<md-tab-body>
<md-tab-content layout-fill flex>
<button ng-click="map.panTo(getPosition());displayMap();"></button>
</md-tab-body>
</md-tab>
</md-tabs>
</md-content>
</div>
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我有:
$scope.selectedIndex = 0;
$scope.displayMap = function() {
$scope.selectedIndex = 1;
};
Run Code Online (Sandbox Code Playgroud)
但是当我点击调用displayMap()的按钮时它根本没有任何效果;
我检查了这个问题:
似乎一切正常......除了标签不会改变.
我正在运行Angular Material 1.0.2
我甚至用$ apply强制更新(没效果):
$scope.selectedIndex = 0;
$scope.displayMap = function () {
$timeout(function () {
if (!$scope.$$phase) {
$scope.$apply(function …Run Code Online (Sandbox Code Playgroud) 我已按照本教程将.NET Core控制台应用程序部署到Azure Web Service WebJob.
我的应用程序在本地运行没有任何问题(使用dotnet 1.0.0-preview2-003131)但是当我尝试从Azure控制台运行它时出现以下错误:
无法从[D:\ local\VirtualDirectory0\site\wwwroot\app_data\jobs\triggered\PopcornExportWebJob\hostpolicy.dll]加载dll,HRESULT:0x800700C1
从[D:\ local\VirtualDirectory0\site\wwwroot\app_data\jobs\triggered\PopcornExportWebJob]加载所需的库hostpolicy.dll时发生错误
Azure dotnet的版本是1.0.0-rc4-004771 ,hostpolicy.dll文件与我在本地使用的文件相同.事实上,当我从Azure下载部署的zip时,当我在本地运行它时,它工作正常.但它在Azure环境中失败了.
另外,这是我的project.json:
{
"publishOptions": {
"include": [
"run.cmd"
]
},
"buildOptions": {
"emitEntryPoint": true,
"copyToOutput": "appsettings.json"
},
"copyright": "bbougot",
"dependencies": {
"FubarCoder.RestSharp.Portable.Core": "4.0.7",
"FubarCoder.RestSharp.Portable.HttpClient": "4.0.7",
"Microsoft.ApplicationInsights.AspNetCore": "2.0.0",
"Microsoft.Extensions.Configuration": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.DependencyInjection": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.NETCore.App": "1.1.0",
"MongoDB.Driver": "2.4.2",
"StructureMap.Microsoft.DependencyInjection": "1.3.0"
},
"description": "Popcorn Api Exporter",
"frameworks": {
"netcoreapp1.1": {
"imports": [
"portable-net45+win8"
]
}
},
"runtimes": {
"win10-x64": {}
}, …Run Code Online (Sandbox Code Playgroud) 我正在尝试启用CORS但是我的AngularJS Web应用程序发送的每个请求都经常出现同样的问题:
跨源请求已阻止:同源策略禁止在https://.../ ... 读取远程资源(原因:缺少CORS标头'Access-Control-Allow-Origin').
它只发生在Firefox上!它与Chrome,Safari,IE和Edge完美配合.
环境:
我的API是托管在Azure App Services(IIS 8.0)上的.NET Web Api 2.3(.NET 4.6).
我的前端应用程序是一个AngularJS webapp,我通过https访问它,并通过https使用API.
我做了什么:我有一个Startup类,它被声明为Owin的启动入口点.
[assembly: OwinStartup(typeof(Startup))]
namespace SentinelleApi
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.Map("/signalr", map =>
{
map.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
EnableDetailedErrors = true,
EnableJavaScriptProxies = false
};
map.RunSignalR(hubConfiguration);
});
HttpConfiguration config = new HttpConfiguration();
WebApiConfig.Register(config);
app.UseWebApi(config);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个WebApiConfig类,声明如下:
namespace SentinelleApi
{
public static class WebApiConfig
{
public static …Run Code Online (Sandbox Code Playgroud) 我想知道将数据库管理到Universal Windows App中的最佳解决方案是什么。我曾经使用过SQL Server Compact CE,但是当然它与UWP不兼容。有没有Microsoft方法可以与Entity很好地集成?
有没有办法在UWP应用程序中拔下耳机插孔时收到通知?我想在没有使用低级API(即:WASAPI)进行编程的情况下执行此操作.
我有一个.NET Core(UWP解决方案)应用程序,它有3个不同的项目(我们称之为A,B和C).
A和B是Windows运行时组件,C是一个简单的类库.
项目A和B参考项目C.
我想访问项目C的一个类,其实例将在项目A和B之间共享.
我想到了单例模式(当然),使用.NET 4的Lazy方法
问题是每次A和B项目访问实例时实例都不一样.Lazy方法创建了该类的新实例,因为它似乎以前没有创建过.我想知道我是否可以在解决方案的不同项目之间共享一个单例.我已经读过一个项目与一个进程相关联,并且每个进程都有自己的内存空间,无法共享.我的问题有解决方案吗?
编辑:这是我的HubService类的实现:
private static readonly Lazy<HubService> Lazy =
new Lazy<HubService>(() => new HubService(), LazyThreadSafetyMode.ExecutionAndPublication);
private HubService()
{
_asyncQueue = new AsyncQueue<Guid>();
}
public static HubService Instance => Lazy.Value;
Run Code Online (Sandbox Code Playgroud)
此外,是否可以使用Castle Windsor,Ninject,Autofac或Unity等工具在不同的程序集之间共享单例?
.net c# design-patterns dependency-injection inversion-of-control
我想知道在.NET应用程序的主线程上执行任务的最佳异步方式是什么(准确地说是在ViewModel中).Dispatcher.BeginInvoke现在仍然有效还是存在更好的方法呢?
我想在Windows 10应用程序中向MapControl添加一个Pushpin,但似乎自Windows 8.1以来控件已经消失.
它很简单:
Pushpin locationPushpin = new Pushpin();
locationPushpin.Background = new SolidColorBrush(Colors.Purple);
locationPushpin.Content = "You are here";
locationPushpin.Tag = "locationPushpin";
locationPushpin.Location = watcher.Position.Location;
this.map.Children.Add(locationPushpin);
this.map.SetView(watcher.Position.Location, 18.0);
Run Code Online (Sandbox Code Playgroud)
但是不再识别图钉类型......
我正在使用Angular Material md-virtual-repeat指令来提高md-list中数千个项目的性能.
但是,当我向下滚动然后向上滚动时,根本不会保留顺序.一开始,我的项目按日期排序,没关系.当我开始滚动时,排序完全搞砸了.
这是我的标记:
<md-virtual-repeat-container class="flex flex-layout md-list indigo" ng-if="tracking.loaded">
<div md-virtual-repeat="marker in tracking.mapMarkers | orderBy: 'timestamp':true" class="md-list-item inset" style="height: 72.6px;">
<div class="md-list-item-content">
<h3 class="text-md">{{ ::marker.timestamp | time }}</h3>
</div>
</div>
</md-virtual-repeat-container>
Run Code Online (Sandbox Code Playgroud)
而我的控制器:
self.mapMarkers = [];
...
// In a function which is called within a promise
_.each(_.without(_.reject(data.Positions, function(position){ return position.Id === currentPosition.Id; })), function (pos) {
var location = new google.maps.LatLng(pos.Latitude, pos.Longitude);
self.mapMarkers.push(new google.maps.Marker({
icon: {
url: "https://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle_blue.png",
size: new google.maps.Size(12, 12),
anchor: new google.maps.Point(4, …Run Code Online (Sandbox Code Playgroud) c# ×6
.net ×4
angularjs ×2
azure ×2
javascript ×2
uwp ×2
asp.net ×1
asp.net-core ×1
async-await ×1
asynchronous ×1
cors ×1
database ×1
sql ×1
windows-10 ×1
winrt-xaml ×1
wpf ×1
xaml ×1