javascript - transmit data to an angularjs controller -


in view in want include java script file witch contains angular module , angular controller

 angular.module("company", []).filter('newlines', function(text){ return text.replace(/&/g, '<br />&');})                 .controller("democontroller", function ($scope, $http) {              $scope.company.title = title // title comme view }             ); 

the data source controller comes view, how can transmit data view controller. in advance

updated answer

if data in model on server, you'll want load via $http, ngresource, or restangular.

$http example (in controller):

$http.get('/server/route/12345').success(function(data){          $scope.company.title = data  } ) 

this assumes "/server/route/12345" route on server returns json object want set directly title.

also, must inject $http controller (which you're doing in example code).

.

previous answer

in html

<input ng-model="viewform.text"> 

in controller

$scope.company.title = $scope.viewform.mytext 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -