How to open a new tab with router.navigate in TypeScript
this is my solution const url = this.router.serializeUrl(this.router.createUrlTree([‘/my/url/route’], { queryParams: { …anyQueryParamsYouWantOrOmitThis } })); window.open(url, ‘_blank’);
this is my solution const url = this.router.serializeUrl(this.router.createUrlTree([‘/my/url/route’], { queryParams: { …anyQueryParamsYouWantOrOmitThis } })); window.open(url, ‘_blank’);
For this situation you can do: <div data-bind=”attr: { ‘class’: selectedPriority}”> The only downside to this method is that it will set the class directly rather than toggle a class on or off, so if you are using multiple classes, then selectedPriority would need to contain the complete list of classes.
There are differences between them. The ko.toJS takes an object and “opens up” and cleans the object from all observables. It does this for the entire object graph. I behaves much like a serializer which means that you’ll run into problems if you have circular references for instance. It uses mapJsObjectGraph internally which is way … Read more
Try to use <span data-bind=”click: function() { function1(); function2() }”></span>
You can use the following trick: ko.computed(function() { return ko.toJSON(complexObject); }).subscribe(function() { // called whenever any of the properties of complexObject changes }); See http://jsfiddle.net/xcajt4qn/3/ The reason why this works is ko.toJSON will recursively read all the properties in the object, therefore making the computed depend on all the properties.
You need to concatenate your strings: data-bind=”style: { backgroundImage: ‘url(\” + image() + ‘\’)’ }” If image is actually an observable, you’ll need to call it, or you’ll end up concatenating the function instead. Note that since you’re binding to an expression involving the property, you must call the function (with ()). Otherwise, you will … Read more
So, there are a few options that you have: KO will have an issue when you try to bind against undefined properties, unless they are off of an object. So, you can prefix your various bindings with $data. and KO will be able to parse your bindings. Sample: http://jsfiddle.net/rniemeyer/dLCL8/ If you know that several properties … Read more
I feel like the existing answers skip over a very important point of confusion: data-bind attributes. It is true that you use the parens when you are in Javascript, and getting or setting observables. But when you are writing data-bind=”text: property”, you leave out the parens even when working with observables. Edit As noted in … Read more
Yes, you can call valueHasMutated function for your array: yourArray.valueHasMutated(); EDIT: If first didn’t help you can do ‘dirty’ refresh: self.refresh = function(){ var data = self.array().slice(0); self.array([]); self.array(data); }; Here is working fiddle: http://jsfiddle.net/vyshniakov/FuEy6/2/
I’ve been using Knockback on a large multi-module project with good results. The docs and examples are unnecessarily complex, so I wrote a blog describing Knockback with some very simple examples and a JSFiddle to get you started. http://www.geekdave.com/?p=79 Feedback is most welcome!