If you are group of youngsters then do cab and save time. but in case you are family with kids then prefer train to Kathgodam and then cab to Nainital. A lot of cabs will be available at railway station to Nainital. if you are travelling alone then cab will be costly and you can't drive all night. if you hire a driver then you can't sleep. in train you have lot of space and comfortable. you have washrooms in Train.
I have a family so i am going via train.