AndreyAkinshin / knockout-mvc

Power of Knockout.js for ASP.NET MVC
http://knockoutmvc.com
203 stars 125 forks source link

Cannot create computed property with bool return type #25

Open JasonRodman opened 11 years ago

JasonRodman commented 11 years ago

For some reason any computed properties that return bool cause the ko.Initialize() method call to fail. For example this fails:

[Computed] public bool HasExpirationDate { get { return true; } }

This will cause this call to fail:

@ko.Initialize(Model)

With the following error:

No coercion operator is defined between types 'System.Int32' and 'System.Boolean'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: No coercion operator is defined between types 'System.Int32' and 'System.Boolean'.

Source Error:

Line 7: { Line 8: @Scripts.Render("~/bundles/scripts/datepicker") Line 9: @ko.Initialize(Model) Line 10: Line 11: Githubissues.

  • Githubissues is a development platform for aggregating issues.