Given
I'm using HTML5 web components via the <link rel="import..." construct. Am
able to breakup large HTML markup into smaller portions and import them at will into a container (web page) that puts all the smaller parts together. Cool so far.
Now I want to use Angular data binding to be able to show dynamic content in those smaller pages. In my main Index.html page I am able to declare the ng-app in the first Div tag no problem. The angular.module is declared in that page as well. I can get the binding to work if I put all controller logic into main page.
Problem
I'd like to do is split each controller script shown below to be contained in the imported page and not just in the main index.html where it's working now.
<script>
angular.module('ResultsApp', [])
.controller('CardsController', ['$scope',
function ($scope) {
$scope.results = {
'Passed': '12',
'Failed': '3',
'Warnings': '5',
'Summary': '20'
}
}
])
.controller('ResultsController', ['$scope',
function ($scope) {
$scope.results = [
{ Name: "The Name of something to display", Passed: "True", Failed: "False", Comments: "These are the comments yes! Comments" },
{ Name: "The Name of something to display", Passed: "True", Failed: "False", Comments: "These are the comments yes! Comments" },
{ Name: "The Name of something to display", Passed: "True", Failed: "False", Comments: "These are the comments yes! Comments" },
{ Name: "The Name of something to display", Passed: "True", Failed: "False", Comments: "These are the comments yes! Comments" },
{ Name: "The Name of something to display", Passed: "True", Failed: "False", Comments: "These are the comments yes! Comments" },
{ Name: "The Name of something to display", Passed: "True", Failed: "False", Comments: "These are the comments yes! Comments" },
{ Name: "The Name of something to display", Passed: "True", Failed: "False", Comments: "These are the comments yes! Comments" },
{ Name: "The Name of something to display", Passed: "True", Failed: "False", Comments: "These are the comments yes! Comments" }
];
}]);
</script>
I've tried putting the controller logic into each imported page but it doesn't seem to work. I am only attempting to use one ng-app defined in main page... Please advise.
Ok if I move the code to a partial page like this, where TestResultsApp is on the main page (Index) call this page "pageheading.html" :
<div class="row" ng-controller="HeaderController">
<div class="col-lg-12">
<h1 class="page-header">
{{header.Title}}
</h1>
<ol class="breadcrumb">
<li class="active">
<i class="fa fa-dashboard">Some Data Here</i>
</li>
</ol>
</div>
</div>
<script>
angular.module('HeaderModule', ['TestResultsApp'])
.controller('HeaderController', ['$scope',
function ($scope) {
$scope.header = { "Title": "Pretty Good, Test Case Results Right here!" }
}])
</script>
The New Error The partial page, can't find angular... More on this tomorrow...