简体   繁体   中英

AngularJS Passing data from view to controller using Laravel PHP call

I want to send some data to the simplecontroller, this data is called from the server by a Laravel or a PHP call. I want to pass it easily like this ng.user.name directive is doing.

<div ng-controller="simplecontroller" id="simplecontroller">
<a href="#" "ng-name={{$company->name}}" "ng-id={{$company->id}}">{{$company->name}}</a>

My controller will use the name and id

app.controller('simplecontroller', function($scope) {
  $scope.user = {
    name = ng-name // or I could call {{$company->name}} here?
    id = ng-id
  }; 

Any way to achieve this functionality? Sorry, but I am SUPER NEW to Angular JS. Please point me to the correct direction.

A lot of confusion in your code. You need to learn angularjs better...

<div ng-controller="simplecontroller" id="simplecontroller">
<a href="#">{{company.name}}</a>
</div>
app.controller('simplecontroller', function($scope) {
  $scope.company = {
    "name":"Comapny Name", "id":"1" 
  };
}); 

This might help - https://www.tutorialspoint.com/angularjs/index.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM