2020年7月31日 星期五

使用 $timeout 注意

$scope destroy 時要 cancel,因為不會自動取消呼叫,若固定周期呼叫則會持續呼叫
$scope.timer = $timeout($scope.onTimeout, 10000);
 $scope.$on(
        "$destroy",
        function (event) {
            $timeout.cancel($scope.timer);
        }
    );

Entity Framework 建立新物件並儲存後馬上取得關聯資料

使用 CreateProxy 建立物件,不要直接 new var newmodel = _contextXXX.CreateProxy<yyy>(); ... _contextXXX.yyy.Add(newmodel); await _contextXXX.SaveC...