Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs 1.3 controller as not working

I am using one controller on two different part of Page, For that i am using alias of controller using "controller as" syntax. But after upgrading to Angular 1.3.15 it is no longer working.Following is the fiddle to simulate the situation.

  1. Working example with 1.2.20

  2. it is not working with 1.3.15

Please let me know if i am making any mistakes.

<div ng-app="myapp">
<div ng-controller="PersonCtrl">
    <input type="text" ng-model="first">
    <p>{{first}}</p>
</div>
<div ng-controller="PersonCtrl as person">
    <p>{{person.$scope.first}}</p>
</div>

like image 501
Bhavin Avatar asked Mar 18 '26 20:03

Bhavin


1 Answers

From : docs.angularjs.org

The isolated scope of a component directive no longer leaks into the template that contains the instance of the directive. This means that you can no longer access the isolated scope from attributes on the element where the isolated directive is defined.

See https://github.com/angular/angular.js/issues/10236 for an example.

Requesting isolate scope and any other scope on a single element is an error. Before this change, the compiler let two directives request a child scope and an isolate scope if the compiler applied them in the order of non-isolate scope directive followed by isolate scope directive.

Now the compiler will error regardless of the order.

like image 75
Kurenai Kunai Avatar answered Mar 21 '26 03:03

Kurenai Kunai