I'm learning Angular JS
coming from a Java background. I've written my first module and I'd like to extend it- from my (beginner) perspective it looks like a Class
which can be extended. So I've coded the following which includes two modules: myApp
and myApp2
.
Angular JS Code:
var myApp = angular.module('myApp', []);
myApp.controller('UserCtrl', ['$scope', function ($scope) {
$scope.name="cat";
$scope.type="pet";
}]);
var myApp2 = angular.module('myApp2', ['myApp']);
myApp2.controller('UserCtrl', ['$scope', function ($scope) {
$scope.name="dog";
}]);
HTML Code
<body ng-app="myApp2">
<div ng-controller="UserCtrl">
<p>{{ name }}</p>
<p>{{ type }}</p>
</div>
In the above example, myApp2
"type" evaluates to "". Is it possible to inherit properties and methods from MyApp
?
Thanks!