1

In my controller:

.controller('ContactCtrl', function($scope, $stateParams, lodash) {

$scope.selectedContact = lodash.findWhere($scope.businesscards, { Id: parseInt($stateParams.contactId) });

console.log($scope.selectedContact);
 });

In my View:

<div class="item">
{{ $scope.selectedContact }}
<h2>{{ $scope.selectedContact.Full_Name }}</h2>
<p>{{ $scope.selectedContact.Company | uppercase }}</p>
</div>

Why I cannot access $scope.selectedContact and even $stateParams.contactId in my view?

2
  • 1
    $scope is implicit in expressions {{ }} and should not be provided. try {{selectedContact}}. Commented Jan 13, 2016 at 10:03
  • use {{selectedContact }} instead of{{ $scope.selectedContact }} Commented Jan 13, 2016 at 10:03

2 Answers 2

2

$scope is the connector between the controller and view. In your case you are defining "selectedContact" variable with $scope when you need to print in controller then you need to do like this ( $scope.selectedContact ) or in view you can simple do {{selectedContact}}

Sign up to request clarification or add additional context in comments.

Comments

1

Use {{ var }} to access $scope.var in your view.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.