Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic link between HTML template & controller #102

Open
angelozerr opened this issue Sep 16, 2014 · 3 comments
Open

Automatic link between HTML template & controller #102

angelozerr opened this issue Sep 16, 2014 · 3 comments

Comments

@angelozerr
Copy link
Owner

See https://thinkster.io/egghead/templateurl/ for a sample with templateUrl.

When templateUrl is used, today link between HTML file and JS controller is done at hand https://github.com/angelozerr/angularjs-eclipse/wiki/Angular-Explorer-View#user-content-html-template-linkunlink

It should be cool if tern plugin angular.js could retrieve the link between HTML template and controller : link will be done automaticly without doing at hand.

@sebastienblanc
Copy link

That would be really nice but also quite complex to implement because there are different situation :

  1. The easy one, the template has a "ng-controller" attribute in its root tag, we can just parse that to make the link
  2. $routeProvider is used to link templates and controllers , like :
 $routeProvider.when('/contacts', {
                templateUrl : 'partials/contact/search.html',
                controller : SearchContactController

Here we need to parse the $routeProvider
3. $stateProvider is used, like :

.state('tab.dash', {
      url: '/dash',
      views: {
        'tab-dash': {
          templateUrl: 'templates/tab-dash.html',
          controller: 'DashCtrl'
        }
      }
    })

There are probably other ways to bind controllers to template which I'm not aware of.

@angelozerr
Copy link
Owner Author

I know it's not an easy task (taht's why I had implemented link 'at hand').

But I would like to really improve (at first) templateUrl with this issue but with the following issue #103 (completion for templateUrl).

But to do that I need that tern support object litteral with clean mean (pay the author of tern.js to support that?)

@angelozerr
Copy link
Owner Author

@sebastienblanc I will start this feature but I will manage for the moment 2 cases :

  • module.directive :
app.directive("zippy", function(){
 return {
   restrict: "E",
   transclude: true,
   scope: {
     title: "@"
   },
   templateUrl: "zippy.html",
   link: function(scope){
     scope.isContentVisible = false;
     scope.toggleContent = function(){
       scope.isContentVisible = !scope.isContentVisible;
     };
   };
 };
});
  • $routeProvider :
$routeProvider.when('/contacts', {
  templateUrl : 'partials/contact/search.html',
  controller : SearchContactController

$stateProvider is not a part of angular, but an extension (so I will not manage it for the moment). I have created an issue for that #137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants