小编dan*_*tch的帖子

使用深层链接刷新html模式角度应用

像我之前的许多人一样,我正在努力让页面刷新与我的角度应用程序一起工作.

我正在使用angular/require/webapi.我从角度电话教程扩展了这个

我把这个项目在GitHub上,以及

这是我目前坐的地方.

我有路线设置.它们处于html模式.他们致力于网站导航.刷新引起了问题.我设置代码Gobal.asax.cs将故障重新路由到index.html.基页(/电话)可以刷新.当刷新详细信息页面(phones/motorola-xoom-with-wi-fi)时会出现错误.

这是我的路线代码

define(['angular', 'app', 'angularRoute'], function (angular, app)
{
    'use strict';

    var myApp = app.config(['$routeProvider', '$provide', '$locationProvider', function ($routeProvider, $provide, $locationProvider) {

        //$provide.decorator('$sniffer', function ($delegate) {
        //    $delegate.history = false;
        //    return $delegate;
        //});

        $routeProvider
            .when('/', {
                redirectTo: '/phones'
            })

            .when('/phones', {
                templateUrl: '../Web/Templates/partials/_phones.html',
                controller: 'PhoneList'
            })

            .when('/phones/:phoneId', {
                templateUrl: '../Web/Templates/partials/_phone-detail.html',
                controller: 'PhoneDetail'
            });
            //.otherwise({
            //    redirectTo: '/phones'
            //});


        // enable html5Mode for pushstate ('#'-less URLs)
        //$locationProvider.hashPrefix('!');
        $locationProvider.html5Mode(true);

    }]);

    return myApp;
}); …
Run Code Online (Sandbox Code Playgroud)

routes requirejs asp.net-web-api angularjs single-page-application

3
推荐指数
1
解决办法
606
查看次数

.net Regex连续两封以上的信件

我试图连续写两封以上的.Net Regex.

aa - fine
Aa - fine
aaa - not allowed
Aaa - not allowed
Run Code Online (Sandbox Code Playgroud)

我是正则表达式的新手,但这是我到目前为止拼凑的内容.

if (Regex.IsMatch(Password, @"/[^A-Za-z]{2}/"))
    return "Password cannot contain 3 consecutive same letters"; 
Run Code Online (Sandbox Code Playgroud)

我不确定这是否接近.

.net regex

2
推荐指数
1
解决办法
2060
查看次数

从Db Set转到字典

我有一个

DbSet<People>
Run Code Online (Sandbox Code Playgroud)

我正试图把它变成一个

Dictionary<int, List<People>>
Run Code Online (Sandbox Code Playgroud)

我的课是

public People
{
     public int Id { get; set; }
     public string Name { get; set; }
     public int Age { get; set; } //this is key of dictionary
}
Run Code Online (Sandbox Code Playgroud)

我想按年龄分组。因此,年龄将是关键,并且要列出所有相同年龄的人。这是获取我的清单的电话

var items = db.People.ToList();
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用ToDictionary方法,但是我不确定这是否是正确的方法。似乎应该有一个lambda语句来实现这一目标。

 Dictionary<int, List<People> myDictionary = items.ToDictionary(p => p.Age, p => People);
Run Code Online (Sandbox Code Playgroud)

.net c# lambda asp.net-mvc-4

2
推荐指数
1
解决办法
1061
查看次数

从BrightScript字符串中删除空格

我试图使用正则表达式从我的字符串中删除前导和尾随空格

regexQuote = CreateObject("roRegex", "/^[ ]+|[ ]+$/g+", "i")
regexQuote.ReplaceAll(noSpaceString)
print noSpaceString
Run Code Online (Sandbox Code Playgroud)

[编辑]

regexQuote = CreateObject("roRegex", "/^[ ]+|[ ]+$/g", "")
print len(noSpaceString) //this value includes leading white spaces, which I dont want
Run Code Online (Sandbox Code Playgroud)

我也试过了

regexQuote = CreateObject("roRegex", "/^[ ]+|[ ]+$/", "")
Run Code Online (Sandbox Code Playgroud)

并尝试过

regexQuote = CreateObject("roRegex", "/(^\s*)|(\s*$)/", "")
Run Code Online (Sandbox Code Playgroud)

brightscript

2
推荐指数
1
解决办法
1058
查看次数

静态下拉列表填充不正确的值

我有一个带有以下html的静态下拉列表.

    <asp:DropDownList width="100px" ID="dropDownActive"  Runat="server">
         <asp:ListItem Text="Inactive" Value="0"/>
         <asp:ListItem Text="Active" Value="1" />
    </asp:DropDownList>
Run Code Online (Sandbox Code Playgroud)

我尝试根据数据填充选定的值,但在我到达它之前它的值为0并且不接受新值.

dropDownActive.SelectedValue = (support.Active)? "Active": "Inactive";
Run Code Online (Sandbox Code Playgroud)

html c#

1
推荐指数
1
解决办法
181
查看次数

结合角度与要求

我经历了这个教程.现在我正在尝试合并需求

我找到了这个解释.

我目前收到错误

Object #<Object> has no method 'unshift'
Run Code Online (Sandbox Code Playgroud)

这是导致错误的代码

require(['jquery', 'angular', 'app/routes/app'], function ($, angular, mainRoutes) {
    //tried this way as well
    //$(function () { // using jQuery because it will run this even if DOM load already happened
    //   angular.bootstrap(document, ['mainApp']);
    //});
    require(['Scripts/app/modules/mainApp.js'], function (mainApp) {
         angular.bootstrap(document.body, [mainApp]);//based of orginal answer
    })
});
Run Code Online (Sandbox Code Playgroud)

我的app.js文件

define(['app/modules/mainApp', 'app/controller/controllers'], function (mainApp) {
  return mainApp.config(['$routeProvider', function ($routeProvider) {
    $routeProvider.
      when('/phones', {
        templateUrl: 'Templates/phone-list.html',
        controller: 'PhoneListCtrl'
      }).
      when('/phones/:phoneId', { …
Run Code Online (Sandbox Code Playgroud)

requirejs angularjs

1
推荐指数
1
解决办法
1126
查看次数