The examples in this article describe how to resolve conflicts between template views and AngularJS. Share it with everyone for your reference, the details are as follows:
Problem:
In the mvc view of php, we need to
pass some data to the template during the loading process:
For example:
Here is a controller
$data['users'] = {something from databases}; $this->load->view('home/index',$data);
Here is the corresponding view
- =$user->name?>:=$user->email?>
- {{user.name}}:{{user.email}}
So now the question is how to deal with the contradiction between 1 and 2?
The first solution:
We store the data passed by php in variables, and then assign it through
$scope, ok
The second solution (recommended):
We use the ng-if attribute to solve our problem, calling php data when users is undefined
After the ajax transfer is completed, use our data and define $scope.users