です。現在、ボタンがプログラムによって作成され、GridLayoutに追加されるTypeScriptアプリケーションを作成しています。NativeScript Button Tapイベントはナビゲーション後にngOnInitを呼び出さないが、onTapは
let currentPage;
let topFrame = frameModule.topmost();
currentPage = topFrame.currentPage;
currentPage.actionBarHidden = true;
currentPage.backgroundImage = currentPage.ios ? "res://baby_large_file.jpg" : "res://baby_large_file";
var onTap = function (eventData) {
this.login();
};
var grid = new GridLayout();
let feeding = new buttonModule.Button();
feeding.text = "F";
feeding.id = "feeding";
feeding.on(buttonModule.Button.tapEvent, onTap, this);
grid.addChild(feeding);
grid.addRow(new ItemSpec(1, GridUnitType.star));
grid.addColumn(new ItemSpec(1, GridUnitType.star));
GridLayout.setRow(feeding, 0);// shareButton set to row 2
GridLayout.setColumn(feeding, 0);// shareButton set to row 2
currentPage.content = grid;
ログイン機能は、単にユーザーサービスを呼び出し、アプリは、彼らが新しいページにルーティングされている有効なトークンを持っている場合:
ngOnInit機能は、この新しいページに呼び出されることはありませんlogin() {
this.userService.login(this.user)
.subscribe(
() => this.router.navigate(["/locations"]),
(error) => alert("Unfortunately we could not find your account.")
);
}
export class Locations implements OnInit {
constructor (private router: Router, private locationService: LocationService) {}
ngOnInit() {
console.log('ngOnInit');
}
}
これが動作しない理由を持つすべてのヘルプは非常に