小编Pra*_*vin的帖子

如何从angular2中的WebMethod获取数据

在使用Ajax的Javascript中

   $.ajax({
    type: "Get",
    url: "AttendanceMaster.aspx/GetDistinctBatch",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    datatype: "jsondata",
    async: "true",       
    success: function(response) {

    },
    error: function(response) {
        alert("(allstudent )" + response.status + ' Error ' + response.statusText);
    }
   });
Run Code Online (Sandbox Code Playgroud)

尝试跟随angular2

  return this._http.get("AttendanceMast.apsx/GetDistinctBatch")
  .map((response) => response.toString());
Run Code Online (Sandbox Code Playgroud)

它返回

{ "_isScalar": false, "source": { "_isScalar": false }, "operator": {} }
Run Code Online (Sandbox Code Playgroud)

C#

 [System.Web.Services.WebMethod]
 public static string GetDistinctBatch()
 {      
    return "welcome Angular 2";
 }
Run Code Online (Sandbox Code Playgroud)

1)如何在angular2中使用?

见下面的错误

在此输入图像描述

http angular

8
推荐指数
2
解决办法
791
查看次数

无法确定类型的复合主键排序

{"无法确定类型'Conference_Project.Models.Login'的复合主键排序.使用ColumnAttribute(请参阅 http://go.microsoft.com/fwlink/?LinkId=386388)或HasKey方法(请参阅http:/ /go.microsoft.com/fwlink/?LinkId=386387)指定复合主键的顺序."}

 [Table("ConferenceLogin")]
public class Login
{

    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public long confid { get; set; }
    [Key]
    public string emailID { get; set; }       
    [Key]
    public string registration { get; set; }
    [Key]
    public long regNo { get; set; }        
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Version Used : EntityFramework.6.1.3  And MVC5
Run Code Online (Sandbox Code Playgroud)

我希望这个独特的价值(emailID,registration,regNo该组则所有的主键的EntityFramework显示错误)

如何在EntityFramework中使用多个主键?

c# entity-framework asp.net-mvc-5

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

数据绑定在angular2中不起作用

    @Component({
      selector: 'my-content',
      templateUrl: `./app/content/content.components.html`
    })
    export class ContentComponent  { 
      _clickLectre: any;
      _temoobj:any;
      private subscription: Subscription;
      constructor(private commonService: CommonService, private dataService: DataService ) {
      }
      ngOnInit() {               
        this.subscription = this.commonService.notifyObservable$.subscribe((res) => {
          if (res.hasOwnProperty('option') && res.option === 'call_Lecture') {                         
                console.log("call"+res.items);            
                this._clickLectre=res.items;
                console.log("call"+this._clickLectre.facultyname);               
          }
        });
      }
      ngOnDestroy() {
        this.subscription.unsubscribe();
      }

    }
Run Code Online (Sandbox Code Playgroud)

HTML

   <tr  *ngIf="_clickLectre">
    <td>Faculty Name : </td>
    <td>{{_clickLectre.facultyname}}</td>
    <td>X</td>
    <td>X</td>
    <td>End Time :</td>
    <td>X </td>
    <td> Present: </td>
    <td>X </td>
   </tr>
Run Code Online (Sandbox Code Playgroud)

我使用了commonService哪种用途将内容从一个组件传输到另一个组件.

上面的this._clickLectre.facultyname值打印在控制台上但它没有反映在html页面上

为什么数据绑定不起作用是什么问题?

提前致谢

angular

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

如何在angular2中选择不同条件下的checbox

在此输入图像描述

   <tr *ngFor="let item of  _studentList">
    <td  align='center'>{{item.rollno}}</td>
    <td  align='center'>{{item.sname}}</td>      
    <td  align='center'>
        <input type='checkbox' style='height:15px; width:15px;' ng-checked="item.status=='P'" ></td>
Run Code Online (Sandbox Code Playgroud)

如果学生Present checbox应该checked如果它Absent然后unchecked我尝试上面但不工作

怎么做?

angular

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

类型'Observable &lt;void&gt;'不可分配给类型'Observable &lt;JSON&gt;'

  getStepList(): Observable<JSON>  {                  
            this.headers = new Headers();
            this.headers.append('Content-Type', 'application/json; charset=utf-8');                
            let options = new RequestOptions({
                method: RequestMethod.Post,
                url: "FeedbackMaster.aspx/getStepList",                   
                headers: this.headers,
                  body:{log:this.login}
            });
            return this._http.request(new Request(options)).retry(2)
            .map((response: Response)=>this.extractData(response))
            .do(data => {this.temp=data, console.log('getStepList:'+ JSON.stringify(JSON.parse(this.temp.d)))})
            .catch(this.handleError);                  
    }

    extractData(res: Response) {
           let body = res.json();
           return body || { }; //<--- not wrapped with data
     }
          handleError(error: any) {
         console.error('An error occurred', error);
          return Promise.reject(error.message || error);
   }  
Run Code Online (Sandbox Code Playgroud)

................................................... ................................................... ...

错误

[ts]
 Type 'Observable<void>' is not assignable to type 'Observable<JSON>'.
 Type 'void' …
Run Code Online (Sandbox Code Playgroud)

angular

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

不更新javascript文件

我正在研究ASP.NET MVC4项目.当我更新JavaScript文件并在浏览器中运行我的项目时.新的更改没有反映在页面上我尝试在IIS服务器上发生同样的事情.为此,每次我必须删除浏览器历史记录然后反映,但这在部署后不正确

还有其他办法吗?

请指导我提前谢谢

javascript asp.net-mvc-4

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

“用户”类型的参数不可分配给“字符串”类型的参数

认证.service.ts

import {Injectable} from '@angular/core';
import {Router} from '@angular/router';

export class User {
constructor(
  public email: string,
  public password: string

 ) { }
 }

var users = [
 new User('admin@admin.com','adm9'),
 new User('user1@gmail.com','a23')
];
@Injectable()
export class AuthenticationService {
 constructor(
  private _router: Router){}
 logout() {
  localStorage.removeItem("user");
  this._router.navigate(['Login']);
}
login(user){
 var authenticatedUser = users.find(u => u.email === user.email);
  if (authenticatedUser){
   localStorage.setItem("user", authenticatedUser);
   this._router.navigate(['Home']);      
   return true;
 }
 return false;
}
 checkCredentials( ){
 if (localStorage.getItem("user") === null){
    this._router.navigate(['Login']);
  }
 } 
}
Run Code Online (Sandbox Code Playgroud)

错误

[at-loader] src\app\authentication\authentication.service.ts:32:36 …

local-storage angular

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

与角形物体比较

跟随我的角度物体

  $scope.obj1= [
    {"NewID":38,"Type":"Faculty","Year":"2016","Status":"Active"},
    {"NewID":39,"Type":"Staff","Year":"2016","Status":"Active"},
    {"NewID":40,"Type":"Faculty","Year":"2016","Status":"Active"},
    {"NewID":41,"Type":"Faculty","Year":"2016","Status":"Active"}
 ]
Run Code Online (Sandbox Code Playgroud)

我想检查'Type'包含任何'Staff'或'Faculty',因为我使用下面的代码

      var myobj=$scope.obj1;

       var x=false; y=false;

          for (var i = 0; i < myobj.length; i++) {
            if ( myobj[i].Type == 'Faculty') {                    
                x=true;
                break;
            }

          }
         for (var i = 0; i < myobj.length; i++) {

            if ( myobj[i].Type == 'Staff') {
                y=true;  
               break;               
            }
          }
Run Code Online (Sandbox Code Playgroud)

我使用JavaScript,我正在寻找角度或JavaScript的简单方法,而不是使用for循环

javascript angularjs

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