Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect scope in Angular #223

Open
sudeep30m opened this issue Jul 6, 2017 · 0 comments
Open

Incorrect scope in Angular #223

sudeep30m opened this issue Jul 6, 2017 · 0 comments

Comments

@sudeep30m
Copy link

sudeep30m commented Jul 6, 2017

<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">

First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>

<div  ng-controller="myCtrl2">

This is 2nd Controller
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>

</div>

Full Name: {{firstName + " " + lastName}}

</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.firstName= "John";
    $scope.lastName= "Doe";
});
app.controller('myCtrl2', function($scope) {
    $scope.firstName= "John";
    $scope.lastName= "Doe";
});

</script>

</body>
</html>

In this code on asking the definition of firstName in {{firstName + " " + lastName}} the plugin highlights code in MyCtrl2 instead of MyCtrl. In the AngularDefinitionQuery the scope was - "scope":{"controllers":["myCtrl2"],"props":{"lastName":"lastName","firstName":"firstName"},"module":"myApp". Instead of myCtrl2 controller the controller should be MyCtrl.

@sudeep30m sudeep30m changed the title Incorrect scope in Angual Incorrect scope in Angular Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant