离子范围值未更新在$ state

时间:2016-04-24 12:53:17

标签: javascript angularjs ionic-framework

https://codepen.io/anon/pen/VaBOwv

.controller('CheckinCtrl', function($scope) {
  $scope.$root.showRight = true;

})

.controller('AttendeesCtrl', function($scope) {

  $scope.$root.showRight = false;
  alert($scope.$root.showRight)
});

我使用ng-show显示隐藏菜单上的右键。但是当我反复尝试时,我发现由于缓存,范围的值不会更新。我不喜欢在州内使用cache:false,因为这对用户来说是一次糟糕的体验。但是如何解决这个问题?

1 个答案:

答案 0 :(得分:4)

http://ionicframework.com/docs/api/directive/ionView/

在输入新视图时,typedef struct { double p_t0; double p_t1; double e; int To_id[460]; int con_size; } Node ; __global__ void pagerank(Node* ingoing, Node* outgoing, int N) { int idx = threadIdx.x + blockIdx.x * blockDim.x ; if ((idx > 0) && (idx < N)) outgoing[idx].p_t1 = ingoing[idx].p_t1; } #include <cstdlib> #define cudaCheck(a) { cudaError_t cuerr = a ; if (cuerr != cudaSuccess) { printf("[ERROR @ %s : %d ] : (%d) - %s\n", __FILE__, __LINE__, cuerr, cudaGetErrorString(cuerr)) ; ::exit(1) ; } } int main() { // int N = 916428 ; // does not fit on my GPU int N = 400000 ; int blockSize; int minGridSize; int gridSize; Node* Nodes = (Node*)malloc(N * sizeof (Node)) ; for (int i = 0 ; i < N ; ++i) Nodes[i].p_t1 = (double)i+1; Node* h_ingoing = Nodes; Node* h_outgoing = (Node*)calloc(N, sizeof *h_outgoing) ; Node* d_ingoing ; Node* d_outgoing ; cudaCheck (cudaMalloc(&d_ingoing, N * sizeof *d_ingoing)); cudaCheck (cudaMalloc(&d_outgoing, N * sizeof *d_outgoing)); cudaCheck (cudaMemcpy (d_ingoing, h_ingoing, N * sizeof *h_ingoing, cudaMemcpyHostToDevice)); cudaCheck (cudaMemcpy (d_outgoing, h_outgoing, N * sizeof *h_outgoing, cudaMemcpyHostToDevice)); float time; cudaEvent_t begin, end ; //blockSize = 256 ; cudaOccupancyMaxPotentialBlockSize<> (&minGridSize, &blockSize, pagerank, 0, N) ; gridSize = (N + blockSize -1) / blockSize ; printf ("Configuration = <<< %d , %d >>>\n", gridSize, blockSize) ; cudaCheck (cudaEventCreate (&begin)) ; cudaCheck (cudaEventCreate (&end)) ; cudaCheck (cudaEventRecord (begin, 0)) ; pagerank <<< gridSize, blockSize >>> (d_ingoing, d_outgoing, N) ; cudaCheck (cudaEventRecord (end, 0)) ; cudaCheck (cudaEventSynchronize (end)) ; cudaCheck (cudaMemcpy (h_outgoing, d_outgoing, N * sizeof *h_outgoing, cudaMemcpyDeviceToHost)) ; for (int i = 0 ; i < 100 ; ++i) { printf ("P_t1[%d] = %f\n", i, h_outgoing[i].p_t1) ; } for (int i = 0 ; i < N ; ++i) { if (h_outgoing[i].p_t1 != (double)(i+1)) printf ("Error @ %d : %lf <> %lf\n", i, h_outgoing[i].p_t1, (double)(i+1)); } return 0 ; } 将广播到$ scope,这是放置代码的地方,如果您希望每次用户进入视图时都执行代码。

将您的代码更改为

RANK()

它应该可行