View不显示Controller的数据

时间:2016-12-23 22:25:27

标签: angularjs twitter-bootstrap angular-ui-router angular-ui-bootstrap

我有4个文件,View,模块,控制器和工厂:

模块:project.module.js

(function () {
'use strict';

angular.module('BlurAdmin.pages.projects', [])
    .config(routeConfig);

/** @ngInject */
function routeConfig($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('projects', {
            url: '/projects',
            template : '<ui-view  autoscroll="true" autoscroll-body-top></ui-view>',
            abstract: true,
            title: 'Les projets',
            Controller : 'ProjectController',
            sidebarMeta: {
                icon: 'ion-compose',
                order: 250,
            },
.state('projects.add', {
            url: '/add',
            templateUrl: 'app/pages/projects/add/addProject.html',
            title: 'Ajouter un projet',
            sidebarMeta: {
                order: 800,
            },
.state('projects.list', {
            url: '/list',
            templateUrl: 'app/pages/projects/list/listProjects.html',
            title: 'List',
            sidebarMeta: {
                order: 900,
            },
 });
    $urlRouterProvider.when('/projects','/projects/list');
}

})();

控制器:ProjectController.js

(function(){
'use strict';

angular.module('BlurAdmin.pages.projects')
                .controller('ProjectController', ProjectController);

function ProjectController($state, $stateParams, $log, $scope, projectFactory) {
<!-- Value to show -->
$scope.addMessage = "see ME";
...}
 })();

工厂:projectFactory.js

function(){
'use strict';

angular.module('BlurAdmin.pages.projects')
  .factory('projectFactory', projectFactory);

function projectFactory($http, $stateParams) {
  var factory = {};
   ....
}})();

查看:addProject.html

 <div class="col-md-6">
    <div
            ba-panel
            ba-panel-title="Ajouter un projet"
            ba-panel-class="with-scroll">

        <form name="ProjectForm" ng-submit="setProject()" ng-init="getProjectById()">

            <!-- Value to show -->

            Show me the add message : {{addMessage}}


            <div class="form-group">
                <label for="titre">Titre du projet</label>
                <input type="text" class="form-control" id="titre" placeholder="Titre">
            </div>
            <div class="form-group" ng-controller="datepickerpopupCtrl">

                <label>Date de début: <em>{{dt | date:'fullDate' }}</em></label>
                <p class="input-group">
                    <input type="text" class="form-control" uib-datepicker-popup="{{format}}" datepicker-options="options" ng-model="dt" is-open="opened" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" show-button-bar="false" />
                    <span class="input-group-btn">
                        <button type="button" class="btn btn-default" ng-click="open()"><i class="glyphicon glyphicon-calendar"></i></button>
                     </span>
                </p>
            </div>
 <section class="col-md-6 col-lg-3">
                <button progress-button="progressFunction()" pb-style="rotate-side-up" class="btn btn-danger">Submit</button>
            </section>
        </form>
        </div>
    </div>
</div>

现在状态被完美地加载并且一切正常但是当我尝试从View中的控制器加载变量时它没有显示。

我正在索引页面中加载脚本:

<script src="app/pages/projects/projects.modules.js"></script>
<script src="app/pages/projects/projectFactory.js"></script>
<script src="app/pages/projects/ProjectController.js"></script>
<script src="app/pages/projects/add/addProject.html"></script>

P.S:我有一个错误,我不知道它是否相关:

  

projects.html:2 Uncaught SyntaxError:意外的标记&lt;

P.S: 我正在使用此BootsTrap template

0 个答案:

没有答案