小编btm*_*ach的帖子

将输入值绑定到ng-click按钮(发送值作为参数)

我正在尝试将输入字段中的值绑定到ng-click上的方法参数.这是我得到的,但它不起作用,我不太确定是否可以这样做?:

<input type="text" name="name" value="{{post.PostId}}" />
<button ng-click="getById(post.PostId)"></button>
<h1>{{post.Title}}</h1>


$scope.getById = function (id) {
        console.log(id);
        return $http.get('/api/Post/' + id);
    }
Run Code Online (Sandbox Code Playgroud)

html javascript angularjs angularjs-ng-click angularjs-ng-model

7
推荐指数
1
解决办法
4万
查看次数

未知提供者:$ resourceProvider - AngularJS

在我的angularjs应用程序上获取以下消息:

Error: [$injector:unpr] Unknown provider: $resourceProvider <- $resource <- Item
http://errors.angularjs.org/1.3.8/$injector/unpr?p0=%24resourceProvider%20%3C-%20%24resource%20%3C-%20Item
    at http://localhost:49717/Scripts/angular.js:63:12
    at http://localhost:49717/Scripts/angular.js:3994:19
    at Object.getService [as get] (http://localhost:49717/Scripts/angular.js:4141:39)
    at http://localhost:49717/Scripts/angular.js:3999:45
    at getService (http://localhost:49717/Scripts/angular.js:4141:39)
    at Object.invoke (http://localhost:49717/Scripts/angular.js:4173:13)
    at Object.enforcedReturnValue [as $get] (http://localhost:49717/Scripts/angular.js:4035:37)
    at Object.invoke (http://localhost:49717/Scripts/angular.js:4182:17)
    at http://localhost:49717/Scripts/angular.js:4000:37
    at getService (http://localhost:49717/Scripts/angular.js:4141:39) <div ng-view="" class="ng-scope">
Run Code Online (Sandbox Code Playgroud)

我的app.js.

'use strict';

var SalesApp = angular.module('SalesApp', ['ngRoute']).
     config(['$routeProvider', function ($routeProvider) {
        $routeProvider.
            when('/', { controller: ItemCtrl, templateUrl: 'item.html' }).
            otherwise({ redirectTo: '/' });
     }]);

SalesApp.factory('Item', function ($resource) {
    return $resource('/api/Item/:iid', { iid: '@iid' }, { …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

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

当其他表格打开时关闭表格

目前的问题是"主屏幕"显示,但立即关闭,我不明白为什么.这是处理新表单的关闭和打开的代码段.

编辑:.这是指Login.cs(对不起)

 if(templogin == true && permission.Equals("1"))
 {
                mainScreen.IsAdmin();
                this.Close();
                mainScreen.ShowDialog();
 }
Run Code Online (Sandbox Code Playgroud)

c# winforms

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

C#中的DataTable列

我目前有这个代码,我知道如何打印行,但我无法弄清楚如何获取我的列标题?我不想使用我已经注释掉的解决方案,因为我想使代码通用,以便我也可以将它用于其他列表.

static DataTable ConvertListToDataTable(List<List<string>> list)
{
    // New table.
    DataTable table = new DataTable();

    /* table.Columns.Add("Employee ID");
       table.Columns.Add("First Name");
       table.Columns.Add("Last Name");
       table.Columns.Add("Job Title");
       table.Columns.Add("Address");
       table.Columns.Add("City"); 
    */

    foreach(List<string> row in list) {
        table.Rows.Add(row.ToArray());
    }

    return table;
}
Run Code Online (Sandbox Code Playgroud)

c# datatable list

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

用于检索单个对象的通用方法c#

我一直在研究这种方法一段时间,并试图弄清楚它是如何工作的.这显然适用于返回完美的对象列表.但我目前无法弄清楚的是我将如何检索单个对象,例如"Employee e"而不是"List"?

public static List<T> DataTableToList<T>(this DataTable table) where T : class, new()
{
    try
    {
        List<T> list = new List<T>();

        foreach (var row in table.AsEnumerable())
        {
            T obj = new T();

            foreach (var prop in obj.GetType().GetProperties())
            {
                try
                {
                    PropertyInfo propertyInfo = obj.GetType().GetProperty(prop.Name);
                    propertyInfo.SetValue(obj, Convert.ChangeType(row[prop.Name], propertyInfo.PropertyType), null);
                }
                catch
                {
                    continue;
                }
            }

            list.Add(obj);
        }

        return list;
    }
    catch
    {
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

c# generics reflection

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

无法在c#中验证日期

当我29/07/1990在文本框中书写时,此代码似乎不起作用.它总是转到else语句.

  string date = tbDate.Text;

  DateTime Test;
  if (DateTime.TryParseExact(date, "MM/dd/yyyy", null, DateTimeStyles.None, out Test) == true) {
    Console.WriteLine("Date OK");
  } else {
    Console.WriteLine("Date Not OK");
  }
Run Code Online (Sandbox Code Playgroud)

.net c#

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