JSFiddle - React, Tailwind, and code Playground
by axiu
HTML
<div ng-controller="MainController as mctrl" ng-init="myFunc()">
this value:{{mctrl.thisObj}}<br/>
scope value:{{scopeObj}}
<div ng-controller="SubController as subCtrl">
<a href="#" ng-click="myFunc()">Change</a><br/>
this value:{{subCtrl.thisObj}}<br/>
scope value:{{scopeObj}}
</div>
</div>
JavaScript
var app = angular.module('myApp',[]);
app.controller('MainController', function ($scope) {
self = this;
$scope.myFunc = function(){
$scope.scopeObj = 'scopeObj value';
self.thisObj = 'thisObj value';
};
});
app.controller('SubController', function ($scope) {
self = this;
$scope.myFunc = function(){
$scope.scopeObj = 'scopeObj value 2';
self.thisObj = 'thisObj value 2';
};
});